diff --git a/ej2-asp-core-mvc/EJ2_ASP.MVC/appearance/figma.md b/ej2-asp-core-mvc/EJ2_ASP.MVC/appearance/figma.md new file mode 100644 index 0000000000..5262421878 --- /dev/null +++ b/ej2-asp-core-mvc/EJ2_ASP.MVC/appearance/figma.md @@ -0,0 +1,79 @@ +--- +layout: post +title: Introduction to the Figma UI Kit in ##Platform_Name## Component | Syncfusion +description: Check out and learn about the introduction to the Figma UI Kit in Syncfusion ##Platform_Name## component of Syncfusion Essential JS 2 and more. +platform: ej2-asp-core-mvc +control: Icons +publishingplatform: ##Platform_Name## +documentation: ug +--- + +# Figma UI Kits for Syncfusion Controls + +Syncfusion offers [Figma UI kits](https://www.figma.com/@syncfusion) to facilitate effective collaboration between designers and developers. The Figma UI kits are available in four themes: [Material 3](https://www.figma.com/community/file/1385969023252455137/syncfusion-ui-kit-material-3-theme), [Fluent](https://www.figma.com/community/file/1385969120047188707/syncfusion-ui-kit-fluent-theme), [Tailwind](https://www.figma.com/community/file/1385969065626384098/syncfusion-ui-kit-tailwind-theme), and [Bootstrap 5](https://www.figma.com/community/file/1385968977953858272/syncfusion-ui-kit-bootstrap-5-theme). These kits match the themes used in Syncfusion controls. + +The kits contain reusable design controls with various possible states and variants, along with detailed figures, measurements, and icons, representing the Syncfusion controls. + +![Material 3](./images/material3.png) + +## Advantages of UI kits + +The Syncfusion Figma UI kit offers the following key advantages: +- The UI kit includes detailed information about Syncfusion controls, such as available control lists, their states, and variants. This facilitates a quick understanding of Syncfusion controls. +- Design controls are developed using the [atomic design methodology](https://atomicdesign.bradfrost.com/chapter-2/), making customization straightforward and efficient. +- Developers can seamlessly match Syncfusion controls with your design requirements, ensuring alignment and accuracy. +- By using standardized controls and themes, the UI kit ensures consistency in your designs, maintaining a uniform look and feel across projects. + +## Downloading the UI kits + +Syncfusion Figma UI kits are available in the [Figma community](https://www.figma.com/@syncfusion). You can download the Syncfusion theme-specific Figma UI kits from the following links: + +- [Material 3](https://www.figma.com/community/file/1385969023252455137/syncfusion-ui-kit-material-3-theme) +- [Fluent](https://www.figma.com/community/file/1385969120047188707/syncfusion-ui-kit-fluent-theme) +- [Tailwind](https://www.figma.com/community/file/1385969065626384098/syncfusion-ui-kit-tailwind-theme) +- [Bootstrap 5](https://www.figma.com/community/file/1385968977953858272/syncfusion-ui-kit-bootstrap-5-theme) + +## Structure of the UI kits + +Syncfusion’s Figma UI kit is structured to offer a comprehensive and user-friendly layout, facilitating easy navigation and exploration of various controls. It includes the following pages: + +- **Thumbnail**: This page serves as the cover page for the UI kit. +- **Index**: Here, users can find a detailed list of all control names, making it simple to identify and locate specific controls within the UI kit. +- **Icons**: Contains a collection of all icons used in the design controls. +- **UI Controls**: At the core of the UI kit, this section features a wide range of essential UI controls. Each control is meticulously designed with detailed figures, measurements, and icons, showcasing various states and variants. + +![Layout](./images/layout.png) + +## Customizing the UI kits + +The Syncfusion Figma UI kits are easily customizable to meet your specific needs, allowing you to create unique designs and adjust colors to match your brand guidelines. The [atomic design methodology](https://atomicdesign.bradfrost.com/chapter-2/) used in developing these controls, your customizations will be seamlessly reflected across multiple controls and their variants. + +Here's how to customize the primary button color of the Material 3 theme within your layout: + +1. Visit our [UI kits](#downloading-the-ui-kits) and choose your preferred theme, such as the Material 3 theme. +2. Open the selected theme in the Figma web application by clicking the **Open in Figma** button. +3. For the desktop application, click the **Import** button in the top-right corner of the page. Select the downloaded Syncfusion fig file you want to import and click the **Open** button. +4. Identify the button you wish to customize within your layout. +5. On the right side of the Figma interface, find the color variable options listed. For example, the variable for a particular button color might be labeled as `$primary-bg-color`, derived from the primary color variable. +6. To customize this primary button control color, click outside the button to see the **Local variables** option on the right side of the Figma interface. It contains the design token for the color variables. Click the **Local variables** option. +7. A popup will show the design token list. You can change the primary color using a color palette. +8. Once you've selected the new color (e.g., pink) for the primary variable, the button's color pattern will be updated accordingly. You'll see the changes reflected in real-time within your design. + +![Customization](./images/customize.png) + +In addition to changing the button color, you can also customize other aspects like font, spacing, shadows, etc., of the UI controls: + +Feel free to experiment with these customization options to create a design that perfectly matches your requirements. + +## Upgrading the UI kits + +To upgrade your UI kits, download the latest version from the provided links. Follow these guidelines for a seamless upgrade process: + +- Keep track of updates or new versions of UI kits from Syncfusion. +- Before upgrading, back up your ongoing projects to prevent data loss or compatibility issues. +- Share your experience with Syncfusion regarding the upgraded UI kits, including any issues encountered or suggestions for improvement. + +## See also + +* [Available themes](https://ej2.syncfusion.com/aspnetmvc/documentation/appearance/theme) +* [Customizing themes](https://ej2.syncfusion.com/aspnetmvc/documentation/appearance/theme-studio#customizing-theme-color-from-theme-studio) \ No newline at end of file diff --git a/ej2-asp-core-mvc/EJ2_ASP.MVC/appearance/images/customize.png b/ej2-asp-core-mvc/EJ2_ASP.MVC/appearance/images/customize.png new file mode 100644 index 0000000000..ce249d0966 Binary files /dev/null and b/ej2-asp-core-mvc/EJ2_ASP.MVC/appearance/images/customize.png differ diff --git a/ej2-asp-core-mvc/EJ2_ASP.MVC/appearance/images/layout.png b/ej2-asp-core-mvc/EJ2_ASP.MVC/appearance/images/layout.png new file mode 100644 index 0000000000..338ecbb343 Binary files /dev/null and b/ej2-asp-core-mvc/EJ2_ASP.MVC/appearance/images/layout.png differ diff --git a/ej2-asp-core-mvc/EJ2_ASP.MVC/appearance/images/material3.png b/ej2-asp-core-mvc/EJ2_ASP.MVC/appearance/images/material3.png new file mode 100644 index 0000000000..7563303d4b Binary files /dev/null and b/ej2-asp-core-mvc/EJ2_ASP.MVC/appearance/images/material3.png differ diff --git a/ej2-asp-core-mvc/EJ2_ASP.NETCORE/appearance/figma.md b/ej2-asp-core-mvc/EJ2_ASP.NETCORE/appearance/figma.md new file mode 100644 index 0000000000..1f9333a698 --- /dev/null +++ b/ej2-asp-core-mvc/EJ2_ASP.NETCORE/appearance/figma.md @@ -0,0 +1,79 @@ +--- +layout: post +title: Introduction to the Figma UI Kit in ##Platform_Name## control | Syncfusion +description: Check out and learn about the introduction to the Figma UI Kit in Syncfusion ##Platform_Name##. Also, listed the icons by theme-wise. +platform: ej2-asp-core-mvc +control: Common +publishingplatform: ##Platform_Name## +documentation: ug +--- + +# Figma UI Kits for Syncfusion Controls + +Syncfusion offers [Figma UI kits](https://www.figma.com/@syncfusion) to facilitate effective collaboration between designers and developers. The Figma UI kits are available in four themes: [Material 3](https://www.figma.com/community/file/1385969023252455137/syncfusion-ui-kit-material-3-theme), [Fluent](https://www.figma.com/community/file/1385969120047188707/syncfusion-ui-kit-fluent-theme), [Tailwind](https://www.figma.com/community/file/1385969065626384098/syncfusion-ui-kit-tailwind-theme), and [Bootstrap 5](https://www.figma.com/community/file/1385968977953858272/syncfusion-ui-kit-bootstrap-5-theme). These kits match the themes used in Syncfusion controls. + +The kits contain reusable design controls with various possible states and variants, along with detailed figures, measurements, and icons, representing the Syncfusion controls. + +![Material 3](./images/material3.png) + +## Advantages of UI kits + +The Syncfusion Figma UI kit offers the following key advantages: +- The UI kit includes detailed information about Syncfusion controls, such as available control lists, their states, and variants. This facilitates a quick understanding of Syncfusion controls. +- Design controls are developed using the [atomic design methodology](https://atomicdesign.bradfrost.com/chapter-2/), making customization straightforward and efficient. +- Developers can seamlessly match Syncfusion controls with your design requirements, ensuring alignment and accuracy. +- By using standardized controls and themes, the UI kit ensures consistency in your designs, maintaining a uniform look and feel across projects. + +## Downloading the UI kits + +Syncfusion Figma UI kits are available in the [Figma community](https://www.figma.com/@syncfusion). You can download the Syncfusion theme-specific Figma UI kits from the following links: + +- [Material 3](https://www.figma.com/community/file/1385969023252455137/syncfusion-ui-kit-material-3-theme) +- [Fluent](https://www.figma.com/community/file/1385969120047188707/syncfusion-ui-kit-fluent-theme) +- [Tailwind](https://www.figma.com/community/file/1385969065626384098/syncfusion-ui-kit-tailwind-theme) +- [Bootstrap 5](https://www.figma.com/community/file/1385968977953858272/syncfusion-ui-kit-bootstrap-5-theme) + +## Structure of the UI kits + +Syncfusion’s Figma UI kit is structured to offer a comprehensive and user-friendly layout, facilitating easy navigation and exploration of various controls. It includes the following pages: + +- **Thumbnail**: This page serves as the cover page for the UI kit. +- **Index**: Here, users can find a detailed list of all control names, making it simple to identify and locate specific controls within the UI kit. +- **Icons**: Contains a collection of all icons used in the design controls. +- **UI Controls**: At the core of the UI kit, this section features a wide range of essential UI controls. Each control is meticulously designed with detailed figures, measurements, and icons, showcasing various states and variants. + +![Layout](./images/layout.png) + +## Customizing the UI kits + +The Syncfusion Figma UI kits are easily customizable to meet your specific needs, allowing you to create unique designs and adjust colors to match your brand guidelines. The [atomic design methodology](https://atomicdesign.bradfrost.com/chapter-2/) used in developing these controls, your customizations will be seamlessly reflected across multiple controls and their variants. + +Here's how to customize the primary button color of the Material 3 theme within your layout: + +1. Visit our [UI kits](#downloading-the-ui-kits) and choose your preferred theme, such as the Material 3 theme. +2. Open the selected theme in the Figma web application by clicking the **Open in Figma** button. +3. For the desktop application, click the **Import** button in the top-right corner of the page. Select the downloaded Syncfusion fig file you want to import and click the **Open** button. +4. Identify the button you wish to customize within your layout. +5. On the right side of the Figma interface, find the color variable options listed. For example, the variable for a particular button color might be labeled as `$primary-bg-color`, derived from the primary color variable. +6. To customize this primary button control color, click outside the button to see the **Local variables** option on the right side of the Figma interface. It contains the design token for the color variables. Click the **Local variables** option. +7. A popup will show the design token list. You can change the primary color using a color palette. +8. Once you've selected the new color (e.g., pink) for the primary variable, the button's color pattern will be updated accordingly. You'll see the changes reflected in real-time within your design. + +![Customization](./images/customize.png) + +In addition to changing the button color, you can also customize other aspects like font, spacing, shadows, etc., of the UI controls: + +Feel free to experiment with these customization options to create a design that perfectly matches your requirements. + +## Upgrading the UI kits + +To upgrade your UI kits, download the latest version from the provided links. Follow these guidelines for a seamless upgrade process: + +- Keep track of updates or new versions of UI kits from Syncfusion. +- Before upgrading, back up your ongoing projects to prevent data loss or compatibility issues. +- Share your experience with Syncfusion regarding the upgraded UI kits, including any issues encountered or suggestions for improvement. + +## See also + +* [Available themes](https://ej2.syncfusion.com/aspnetcore/documentation/appearance/theme) +* [Customizing themes](https://ej2.syncfusion.com/aspnetcore/documentation/appearance/theme-studio#customizing-theme-color-from-theme-studio) diff --git a/ej2-asp-core-mvc/EJ2_ASP.NETCORE/appearance/images/customize.png b/ej2-asp-core-mvc/EJ2_ASP.NETCORE/appearance/images/customize.png new file mode 100644 index 0000000000..ce249d0966 Binary files /dev/null and b/ej2-asp-core-mvc/EJ2_ASP.NETCORE/appearance/images/customize.png differ diff --git a/ej2-asp-core-mvc/EJ2_ASP.NETCORE/appearance/images/layout.png b/ej2-asp-core-mvc/EJ2_ASP.NETCORE/appearance/images/layout.png new file mode 100644 index 0000000000..338ecbb343 Binary files /dev/null and b/ej2-asp-core-mvc/EJ2_ASP.NETCORE/appearance/images/layout.png differ diff --git a/ej2-asp-core-mvc/EJ2_ASP.NETCORE/appearance/images/material3.png b/ej2-asp-core-mvc/EJ2_ASP.NETCORE/appearance/images/material3.png new file mode 100644 index 0000000000..7563303d4b Binary files /dev/null and b/ej2-asp-core-mvc/EJ2_ASP.NETCORE/appearance/images/material3.png differ diff --git a/ej2-asp-core-mvc/code-snippet/document-editor-container/comments-mention/razor b/ej2-asp-core-mvc/code-snippet/document-editor-container/comments-mention/razor index e17a73cb43..4ee6c2c0df 100644 --- a/ej2-asp-core-mvc/code-snippet/document-editor-container/comments-mention/razor +++ b/ej2-asp-core-mvc/code-snippet/document-editor-container/comments-mention/razor @@ -8,29 +8,9 @@ container = documenteditorElement.ej2_instances[0]; documenteditor = container.documentEditor; let mentionData = [ - { "Name": "Selma Rose", "Eimg": "3", "EmailId": "selma@mycompany.com" }, - { "Name": "Russo Kay", "Eimg": "8", "EmailId": "russo@mycompany.com" }, - { "Name": "Camden Kate", "Eimg": "9", "EmailId": "camden@mycompany.com" }, - { "Name": "Mary Kate", "Eimg": "4", "EmailId": "marry@mycompany.com" }, - { "Name": "Ursula Ann", "Eimg": "2", "EmailId": "ursula@mycompany.com" }, - { "Name": "Margaret", "Eimg": "5", "EmailId": "margaret@mycompany.com" }, - { "Name": "Laura Grace", "Eimg": "6", "EmailId": "laura@mycompany.com" }, - { "Name": "Robert", "Eimg": "8", "EmailId": "robert@mycompany.com" }, - { "Name": "Albert", "Eimg": "9", "EmailId": "albert@mycompany.com" }, - { "Name": "Michale", "Eimg": "10", "EmailId": "michale@mycompany.com" }, - { "Name": "Andrew James", "Eimg": "7", "EmailId": "james@mycompany.com" }, - { "Name": "Rosalie", "Eimg": "4", "EmailId": "rosalie@mycompany.com" }, - { "Name": "Stella Ruth", "Eimg": "2", "EmailId": "stella@mycompany.com" }, - { "Name": "Richard Rose", "Eimg": "10", "EmailId": "richard@mycompany.com" }, - { "Name": "Gabrielle", "Eimg": "3", "EmailId": "gabrielle@mycompany.com" }, - { "Name": "Thomas", "Eimg": "7", "EmailId": "thomas@mycompany.com" }, - { "Name": "Charles Danny", "Eimg": "8", "EmailId": "charles@mycompany.com" }, - { "Name": "Daniel", "Eimg": "10", "EmailId": "daniel@mycompany.com" }, - { "Name": "Matthew", "Eimg": "7", "EmailId": "matthew@mycompany.com" }, - { "Name": "Donald Krish", "Eimg": "9", "EmailId": "donald@mycompany.com" }, - { "Name": "Yohana", "Eimg": "1", "EmailId": "yohana@mycompany.com" }, - { "Name": "Kevin Paul", "Eimg": "10", "EmailId": "kevin@mycompany.com" }, - { "Name": "Andrew Fuller", "Eimg": "3", "EmailId": "andrew@mycompany.com"} + { "Name": "Mary Kate", "EmailId": "marry@company.com" }, + { "Name": "Andrew James", "EmailId": "james@company.com" }, + { "Name": "Andrew Fuller", "EmailId": "andrew@company.com"} ]; container.documentEditorSettings.mentionSettings = { dataSource: mentionData, fields: { text: 'Name' }}; } diff --git a/ej2-asp-core-mvc/code-snippet/document-editor-container/comments-mention/tagHelper b/ej2-asp-core-mvc/code-snippet/document-editor-container/comments-mention/tagHelper index ff5280635c..9cb0f15ead 100644 --- a/ej2-asp-core-mvc/code-snippet/document-editor-container/comments-mention/tagHelper +++ b/ej2-asp-core-mvc/code-snippet/document-editor-container/comments-mention/tagHelper @@ -9,29 +9,9 @@ container = documenteditorElement.ej2_instances[0]; documenteditor = container.documentEditor; let mentionData = [ - { "Name": "Selma Rose", "Eimg": "3", "EmailId": "selma@mycompany.com" }, - { "Name": "Russo Kay", "Eimg": "8", "EmailId": "russo@mycompany.com" }, - { "Name": "Camden Kate", "Eimg": "9", "EmailId": "camden@mycompany.com" }, - { "Name": "Mary Kate", "Eimg": "4", "EmailId": "marry@mycompany.com" }, - { "Name": "Ursula Ann", "Eimg": "2", "EmailId": "ursula@mycompany.com" }, - { "Name": "Margaret", "Eimg": "5", "EmailId": "margaret@mycompany.com" }, - { "Name": "Laura Grace", "Eimg": "6", "EmailId": "laura@mycompany.com" }, - { "Name": "Robert", "Eimg": "8", "EmailId": "robert@mycompany.com" }, - { "Name": "Albert", "Eimg": "9", "EmailId": "albert@mycompany.com" }, - { "Name": "Michale", "Eimg": "10", "EmailId": "michale@mycompany.com" }, - { "Name": "Andrew James", "Eimg": "7", "EmailId": "james@mycompany.com" }, - { "Name": "Rosalie", "Eimg": "4", "EmailId": "rosalie@mycompany.com" }, - { "Name": "Stella Ruth", "Eimg": "2", "EmailId": "stella@mycompany.com" }, - { "Name": "Richard Rose", "Eimg": "10", "EmailId": "richard@mycompany.com" }, - { "Name": "Gabrielle", "Eimg": "3", "EmailId": "gabrielle@mycompany.com" }, - { "Name": "Thomas", "Eimg": "7", "EmailId": "thomas@mycompany.com" }, - { "Name": "Charles Danny", "Eimg": "8", "EmailId": "charles@mycompany.com" }, - { "Name": "Daniel", "Eimg": "10", "EmailId": "daniel@mycompany.com" }, - { "Name": "Matthew", "Eimg": "7", "EmailId": "matthew@mycompany.com" }, - { "Name": "Donald Krish", "Eimg": "9", "EmailId": "donald@mycompany.com" }, - { "Name": "Yohana", "Eimg": "1", "EmailId": "yohana@mycompany.com" }, - { "Name": "Kevin Paul", "Eimg": "10", "EmailId": "kevin@mycompany.com" }, - { "Name": "Andrew Fuller", "Eimg": "3", "EmailId": "andrew@mycompany.com"} + { "Name": "Mary Kate", "EmailId": "marry@company.com" }, + { "Name": "Andrew James", "EmailId": "james@company.com" }, + { "Name": "Andrew Fuller", "EmailId": "andrew@company.com"} ]; container.documentEditorSettings.mentionSettings = { dataSource: mentionData, fields: { text: 'Name' }}; } diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/auto-primary/primary.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/auto-primary/primary.cs new file mode 100644 index 0000000000..8becfe6081 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/auto-primary/primary.cs @@ -0,0 +1,6 @@ +public IActionResult Index() +{ + var Order = OrderDetails.GetAllRecords(); + ViewBag.dataSource = Order; + return View(); +} \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/primary/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/auto-primary/razor similarity index 63% rename from ej2-asp-core-mvc/code-snippet/grid/columns/primary/razor rename to ej2-asp-core-mvc/code-snippet/grid/columns/auto-primary/razor index 66be67f99c..de350aaddb 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/columns/primary/razor +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/auto-primary/razor @@ -2,8 +2,6 @@ diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/auto-primary/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/auto-primary/tagHelper new file mode 100644 index 0000000000..f88cb4f2b8 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/auto-primary/tagHelper @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/auto/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/auto/razor index ce978cae52..adc629c241 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/columns/auto/razor +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/auto/razor @@ -1 +1 @@ -@Html.EJS().Grid("Auto").DataSource((IEnumerable)ViewBag.dataSource).Render() \ No newline at end of file +@Html.EJS().Grid("Auto").AllowPaging(true).DataSource((IEnumerable)ViewBag.DataSource).Render() \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/auto/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/auto/tagHelper index 41a74d15f1..b3f635c106 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/columns/auto/tagHelper +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/auto/tagHelper @@ -1,3 +1,2 @@ - - + diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/autocolumnformat/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/autocolumnformat/razor index dd6343e9dc..3bd43b3909 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/columns/autocolumnformat/razor +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/autocolumnformat/razor @@ -1,17 +1,19 @@ -@Html.EJS().Grid("Auto").DataSource((IEnumerable)ViewBag.dataSource).DataBound("dataBound").Render() - +@Html.EJS().Grid("Auto").DataSource((IEnumerable)ViewBag.DataSource).DataBound("dataBound").Render() \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/autocolumnformat/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/autocolumnformat/tagHelper index 0b1293565f..217aa103d2 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/columns/autocolumnformat/tagHelper +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/autocolumnformat/tagHelper @@ -4,16 +4,19 @@ \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/column-render-array/arraytypecolumns.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/column-render-array/arraytypecolumns.cs new file mode 100644 index 0000000000..c64d4d3451 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/column-render-array/arraytypecolumns.cs @@ -0,0 +1,6 @@ +public IActionResult Index() +{ + var ComplexData = ComplexData.GetAllRecords(); + ViewBag.DataSource = ComplexData; + return View(); +} \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/column-render-array/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/column-render-array/razor new file mode 100644 index 0000000000..0c2f58d53f --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/column-render-array/razor @@ -0,0 +1,16 @@ +@{ + var valueAccess = "valueAccessFn"; +} + +@Html.EJS().Grid("Grid").DataSource((IEnumerable)ViewBag.DataSource).Height(350).Columns(col => +{ + col.Field("EmployeeID").HeaderText("Employee ID").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Width("120").Add(); + col.Field("Name").HeaderText("Full Name").ValueAccessor(valueAccess).Width("150").Add(); + col.Field("Title").HeaderText("Title").Width("150").Add(); +}).Render() + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/column-render-array/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/column-render-array/tagHelper new file mode 100644 index 0000000000..039c655690 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/column-render-array/tagHelper @@ -0,0 +1,17 @@ +@{ + var valueAccess = "valueAccessFn"; +} + + + + + + + + + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/column-render-expression/expressioncolumn.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/column-render-expression/expressioncolumn.cs new file mode 100644 index 0000000000..52bca32b62 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/column-render-expression/expressioncolumn.cs @@ -0,0 +1,6 @@ +public IActionResult Index() +{ + var Order = FoodDetails.GetAllRecords(); + ViewBag.DataSource = Order; + return View(); +} \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/column-render-expression/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/column-render-expression/razor new file mode 100644 index 0000000000..884e90db4c --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/column-render-expression/razor @@ -0,0 +1,19 @@ +@{ + var totalCalories = "totalCaloriesFn"; +} + +@Html.EJS().Grid("ValueAccessor").DataSource((IEnumerable)ViewBag.DataSource).Height(350).Columns(col => +{ + col.Field("FoodName").HeaderText("Food Name").Width("150").Add(); + col.Field("Protein").HeaderText("Protein").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Width("120").Add(); + col.Field("Fat").HeaderText("Fat").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Width("80").Add(); + col.Field("Carbohydrate").HeaderText("Carbohydrate").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Width("120").Add(); + col.HeaderText("Calories Intake").ValueAccessor(totalCalories).TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Width("150").Add(); + +}).Render() + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/column-render-expression/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/column-render-expression/tagHelper new file mode 100644 index 0000000000..b37cc8ad2e --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/column-render-expression/tagHelper @@ -0,0 +1,19 @@ +@{ + var totalCalories = "totalCaloriesFn"; +} + + + + + + + + + + + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/column-render-remote/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/column-render-remote/razor new file mode 100644 index 0000000000..78aee1bd5a --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/column-render-remote/razor @@ -0,0 +1,12 @@ +@Html.EJS().Grid("Grid").DataSource(dataManger => +{ + dataManger.Url("https://services.odata.org/V4/Northwind/Northwind.svc/Orders/").CrossDomain(true).Adaptor("ODataV4Adaptor"); + +}).Query("new ej.data.Query().expand('Employee')").Columns(col => +{ + col.Field("OrderID").HeaderText("Order ID").Width("100").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("CustomerID").HeaderText("Customer Name").Width("120").Add(); + col.Field("ShipCity").HeaderText("Ship City").Width("130").Add(); + col.Field("Employee.City").HeaderText("City").Width("130").Add(); + +}).AllowPaging().Render() \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/columnmenuevents/columnmenuevents.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/column-render-remote/remotedata.cs similarity index 100% rename from ej2-asp-core-mvc/code-snippet/grid/columns/columnmenuevents/columnmenuevents.cs rename to ej2-asp-core-mvc/code-snippet/grid/columns/column-render-remote/remotedata.cs diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/column-render-remote/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/column-render-remote/tagHelper new file mode 100644 index 0000000000..e62f7f8cf8 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/column-render-remote/tagHelper @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/column-render-serial/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/column-render-serial/razor new file mode 100644 index 0000000000..0bb5cf6f8d --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/column-render-serial/razor @@ -0,0 +1,23 @@ +@Html.EJS().Grid("Grid").DataSource((IEnumerable)ViewBag.dataSource).Height(350).Columns(col => +{ + col.HeaderText("S.No").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Center).Width("90").Add(); + col.Field("OrderID").HeaderText("Order ID").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Width("120").Add(); + col.Field("CustomerID").HeaderText("Customer Name").Width("150").Add(); + col.Field("Freight").HeaderText("Freight").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Width("120").Add(); + col.Field("ShipCity").HeaderText("Ship City").Width("150").Add(); +}).AllowPaging().RowDataBound("rowDataBound").Render() + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/column-render-serial/serialnumber.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/column-render-serial/serialnumber.cs new file mode 100644 index 0000000000..931c902716 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/column-render-serial/serialnumber.cs @@ -0,0 +1,6 @@ +public IActionResult Index() +{ + var Order = OrdersDetails.GetAllRecords(); + ViewBag.dataSource = Order; + return View(); +} \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/column-render-serial/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/column-render-serial/tagHelper new file mode 100644 index 0000000000..eb5efdd3c3 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/column-render-serial/tagHelper @@ -0,0 +1,23 @@ + + + + + + + + + + diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/column-render-valueaccessor/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/column-render-valueaccessor/razor new file mode 100644 index 0000000000..df5424d2da --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/column-render-valueaccessor/razor @@ -0,0 +1,21 @@ +@{ + var currencyFormatter = "currencyFormatterFn"; + var concatenateFields = "concatenateFieldsFn"; +} + +@Html.EJS().Grid("ValueAccessor").DataSource((IEnumerable)ViewBag.DataSource).Height(350).Columns(col => +{ + col.Field("OrderID").HeaderText("Order ID").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Width("120").Add(); + col.Field("CustomerID").HeaderText("Customer Name").Width("150").Add(); + col.Field("Freight").HeaderText("Freight").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Width("120").ValueAccessor(currencyFormatter).Add(); + col.Field("ShipCity").HeaderText("Ship City").ValueAccessor(concatenateFields).Width("150").Add(); +}).Render() + + diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/column-render-valueaccessor/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/column-render-valueaccessor/tagHelper new file mode 100644 index 0000000000..e12cf02564 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/column-render-valueaccessor/tagHelper @@ -0,0 +1,23 @@ +@{ + var currencyFormatter = "currencyFormatterFn"; + var concatenateFields = "concatenateFieldsFn"; +} + + + + + + + + + + + diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/column-render-valueaccessor/valueaccessor.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/column-render-valueaccessor/valueaccessor.cs new file mode 100644 index 0000000000..fea0f40648 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/column-render-valueaccessor/valueaccessor.cs @@ -0,0 +1,6 @@ +public IActionResult Index() +{ + var Order = OrdersDetails.GetAllRecords(); + ViewBag.DataSource = Order; + return View(); +} diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/primary/primary.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/column-rendering/column-rendering.cs similarity index 100% rename from ej2-asp-core-mvc/code-snippet/grid/columns/primary/primary.cs rename to ej2-asp-core-mvc/code-snippet/grid/columns/column-rendering/column-rendering.cs diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/column-rendering/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/column-rendering/razor new file mode 100644 index 0000000000..c1ee428ee1 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/column-rendering/razor @@ -0,0 +1,9 @@ +@Html.EJS().Grid("Grid").DataSource((IEnumerable)ViewBag.DataSource).Columns(col => +{ + col.Field("OrderID").HeaderText("Order ID").Width("100").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("CustomerID").HeaderText("Customer ID").Width("120").Add(); + col.Field("Freight").HeaderText("Freight").Width("80").Format("C2").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("OrderDate").HeaderText("Order Date").Width("80").Format("yMd").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("ShipCity").HeaderText("Ship Country").Width("120").Add(); + +}).Render() \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/column-rendering/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/column-rendering/tagHelper new file mode 100644 index 0000000000..2ad0834288 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/column-rendering/tagHelper @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser-contains/columnchooser.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser-contains/columnchooser.cs new file mode 100644 index 0000000000..a313f00f64 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser-contains/columnchooser.cs @@ -0,0 +1,6 @@ +public IActionResult Index() +{ + var Order = OrdersDetails.GetAllRecords(); + ViewBag.DataSource = Order; + return View(); +} \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser-contains/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser-contains/razor new file mode 100644 index 0000000000..0df9804a6e --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser-contains/razor @@ -0,0 +1,8 @@ +@Html.EJS().Grid("Grid").DataSource((IEnumerable)ViewBag.DataSource).ShowColumnChooser(true).Columns(col => +{ + col.Field("OrderID").HeaderText("Order ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("CustomerID").HeaderText("Customer ID").Width("130").Add(); + col.Field("Freight").HeaderText("Freight").Width("120").Format("C").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("OrderDate").HeaderText("Order Date").Width("130").Format("yMd").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("ShipCountry").HeaderText("Ship Country").Width("120").Add(); +}).Toolbar(new List() { "ColumnChooser" }).ColumnChooserSettings(choose=> { choose.Operator("Contains"); }).Render() diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser-contains/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser-contains/tagHelper new file mode 100644 index 0000000000..7c6a7cb598 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser-contains/tagHelper @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser-diacritics/columnchooser.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser-diacritics/columnchooser.cs new file mode 100644 index 0000000000..a313f00f64 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser-diacritics/columnchooser.cs @@ -0,0 +1,6 @@ +public IActionResult Index() +{ + var Order = OrdersDetails.GetAllRecords(); + ViewBag.DataSource = Order; + return View(); +} \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser-diacritics/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser-diacritics/razor new file mode 100644 index 0000000000..89f0215ba8 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser-diacritics/razor @@ -0,0 +1,8 @@ +@Html.EJS().Grid("Grid").DataSource((IEnumerable)ViewBag.DataSource).ShowColumnChooser(true).Columns(col => +{ + col.Field("ÒrderID̂").HeaderText("Òrder ID̂").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("CustomerID").HeaderText("Customer ID").Width("130").Add(); + col.Field("F̂reight").HeaderText("F̂reight").Width("120").Format("C").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("OrderDate").HeaderText("Order Date").Width("130").Format("yMd").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("ShipCountry").HeaderText("Ship Country").Width("120").Add(); +}).Toolbar(new List() { "ColumnChooser" }).ColumnChooserSettings(choose => { choose.IgnoreAccent(true); }).Render() \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser-diacritics/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser-diacritics/tagHelper new file mode 100644 index 0000000000..da1b269679 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser-diacritics/tagHelper @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser-external/columnchooser.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser-external/columnchooser.cs new file mode 100644 index 0000000000..a313f00f64 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser-external/columnchooser.cs @@ -0,0 +1,6 @@ +public IActionResult Index() +{ + var Order = OrdersDetails.GetAllRecords(); + ViewBag.DataSource = Order; + return View(); +} \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser-external/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser-external/razor new file mode 100644 index 0000000000..80979ed8ef --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser-external/razor @@ -0,0 +1,17 @@ +
+ @Html.EJS().Button("show")..CssClass("e-primary").Content("open Column Chooser").Render() +
+@Html.EJS().Grid("Grid").DataSource((IEnumerable)ViewBag.DataSource).ShowColumnChooser(true).Columns(col => +{ + col.Field("OrderID").HeaderText("Order ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("CustomerID").HeaderText("Customer ID").Width("130").Add(); + col.Field("Freight").HeaderText("Freight").Width("120").Format("C").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("OrderDate").HeaderText("Order Date").Width("130").Format("yMd").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("ShipCountry").HeaderText("Ship Country").Width("120").Add(); +}).Render() + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser-external/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser-external/tagHelper new file mode 100644 index 0000000000..cb51a6087b --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser-external/tagHelper @@ -0,0 +1,19 @@ +
+ +
+ + + + + + + + + + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser-hide/columnchooser.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser-hide/columnchooser.cs new file mode 100644 index 0000000000..a313f00f64 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser-hide/columnchooser.cs @@ -0,0 +1,6 @@ +public IActionResult Index() +{ + var Order = OrdersDetails.GetAllRecords(); + ViewBag.DataSource = Order; + return View(); +} \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser-hide/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser-hide/razor new file mode 100644 index 0000000000..85efbe3b53 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser-hide/razor @@ -0,0 +1,8 @@ +@Html.EJS().Grid("Grid").DataSource((IEnumerable)ViewBag.DataSource).Height("270px").ShowColumnChooser(true).Columns(col => +{ + col.Field("OrderID").HeaderText("Order ID").Width("120").ShowInColumnChooser(false).TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("CustomerID").HeaderText("Customer ID").Width("130").Add(); + col.Field("Freight").HeaderText("Freight").Width("120").Format("C").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("OrderDate").HeaderText("Order Date").Width("130").Format("yMd").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("ShipCountry").HeaderText("Ship Country").Width("120").Add(); +}).Toolbar(new List() { "ColumnChooser" }).Render() \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser-hide/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser-hide/tagHelper new file mode 100644 index 0000000000..9c92958b15 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser-hide/tagHelper @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser-size/columnchooser.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser-size/columnchooser.cs new file mode 100644 index 0000000000..a313f00f64 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser-size/columnchooser.cs @@ -0,0 +1,6 @@ +public IActionResult Index() +{ + var Order = OrdersDetails.GetAllRecords(); + ViewBag.DataSource = Order; + return View(); +} \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser-size/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser-size/razor new file mode 100644 index 0000000000..9faa7dd1c0 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser-size/razor @@ -0,0 +1,19 @@ +@Html.EJS().Grid("Grid").DataSource((IEnumerable)ViewBag.DataSource).ShowColumnChooser(true).Columns(col => +{ + col.Field("OrderID").HeaderText("Order ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("CustomerID").HeaderText("Customer ID").Width("130").Add(); + col.Field("Freight").HeaderText("Freight").Width("120").Format("C").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("OrderDate").HeaderText("Order Date").Width("130").Format("yMd").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("ShipCountry").HeaderText("Ship Country").Width("120").Add(); +}).Toolbar(new List() { "ColumnChooser" }).Render() + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser-size/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser-size/tagHelper new file mode 100644 index 0000000000..02817bd563 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser-size/tagHelper @@ -0,0 +1,19 @@ + + + + + + + + + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser/columnchooser.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser/columnchooser.cs index f6f0126ac7..a313f00f64 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser/columnchooser.cs +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser/columnchooser.cs @@ -1,6 +1,6 @@ public IActionResult Index() { - var Order = OrderDetails.GetAllRecords(); + var Order = OrdersDetails.GetAllRecords(); ViewBag.DataSource = Order; return View(); } \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser/razor index f0394688c1..2c228663b7 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser/razor +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser/razor @@ -1,11 +1,8 @@ -@Html.EJS().Grid("ColumnChooser").DataSource((IEnumerable)ViewBag.DataSource).ShowColumnChooser(true).Columns(col => +@Html.EJS().Grid("Grid").DataSource((IEnumerable)ViewBag.DataSource).Height("270px").ShowColumnChooser(true).Columns(col => { col.Field("OrderID").HeaderText("Order ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); - col.Field("CustomerID").HeaderText("Customer Name").Width("150").ShowInColumnChooser(false).Add(); + col.Field("CustomerID").HeaderText("Customer ID").Width("130").Add(); + col.Field("Freight").HeaderText("Freight").Width("120").Format("C").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); col.Field("OrderDate").HeaderText("Order Date").Width("130").Format("yMd").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); - col.Field("Freight").HeaderText("Freight").Width("120").Format("C2").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); - col.Field("ShippedDate").HeaderText("Shipped Date").Width("140").Format("yMd").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); - col.Field("ShipCity").Visible(false).HeaderText("Ship Country").Width("150").Visible(false).Add(); - col.Field("ShipCountry").Visible(false).HeaderText("Ship Country").Width("150").Add(); - -}).AllowPaging().Toolbar(new List() { "ColumnChooser" }).Render() \ No newline at end of file + col.Field("ShipCountry").HeaderText("Ship Country").Width("120").Add(); +}).Toolbar(new List() { "ColumnChooser" }).Render() \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser/tagHelper index 3a1bb75a71..f9a1c619db 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser/tagHelper +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/columnchooser/tagHelper @@ -1,12 +1,9 @@ - + - - - - - - - + + + + + - - + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/columnmenu-stacked/columnmenu.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/columnmenu-stacked/columnmenu.cs new file mode 100644 index 0000000000..a313f00f64 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/columnmenu-stacked/columnmenu.cs @@ -0,0 +1,6 @@ +public IActionResult Index() +{ + var Order = OrdersDetails.GetAllRecords(); + ViewBag.DataSource = Order; + return View(); +} \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/columnmenu-stacked/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/columnmenu-stacked/razor new file mode 100644 index 0000000000..3bbd7720c8 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/columnmenu-stacked/razor @@ -0,0 +1,46 @@ +@{ + var columnMenuItems = new List + { + "SortAscending", + "SortDescending", + "Group", + "Ungroup", + "Filter", + new + { + text = "Sub Menu", + items = new List + { + new { text = "Option 1", id = "option1" }, + new { text = "Option 2", id = "option2" }, + new { text = "Option 3", id = "option3" }, + new + { + text = "Nested Sub Menu", + items = new List + { + new { text = "Nested Option 1", id = "nestedoption1" }, + new { text = "Nested Option 2", id = "nestedoption2" } + } + } + } + } + }; +} + +@Html.EJS().Grid("Grid").DataSource((IEnumerable)ViewBag.DataSource).ShowColumnMenu(true).AllowSorting().AllowFiltering(true).AllowGrouping().Columns(col => +{ + col.Field("OrderID").HeaderText("Order ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("CustomerID").HeaderText("Customer ID").Width("120").Add(); + col.Field("Freight").HeaderText("Freight").Width("130").Format("C").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("ShipCity").HeaderText("Ship City").Width("130").Add(); + col.Field("ShipCountry").HeaderText("Ship Country").Width("130").Add(); +}).ColumnMenuItems(columnMenuItems).ColumnMenuClick("columnMenuClick").FilterSettings(filter => { filter.Type(Syncfusion.EJ2.Grids.FilterType.CheckBox); }).GroupSettings(group => { group.ShowGroupedColumn(true); }).AllowPaging().Render() + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/columnmenu-stacked/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/columnmenu-stacked/tagHelper new file mode 100644 index 0000000000..a7224fcf60 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/columnmenu-stacked/tagHelper @@ -0,0 +1,50 @@ +@{ + + var columnMenuItems = new List + { + "SortAscending", + "SortDescending", + "Group", + "Ungroup", + "Filter", + new + { + text = "Sub Menu", + items = new List + { + new { text = "Option 1", id = "option1" }, + new { text = "Option 2", id = "option2" }, + new { text = "Option 3", id = "option3" }, + new + { + text = "Nested Sub Menu", + items = new List + { + new { text = "Nested Option 1", id = "nestedoption1" }, + new { text = "Nested Option 2", id = "nestedoption2" } + } + } + } + } + }; + +} + + + + + + + + + + + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/columnmenu/columnmenu.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/columnmenu/columnmenu.cs index f6f0126ac7..a313f00f64 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/columns/columnmenu/columnmenu.cs +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/columnmenu/columnmenu.cs @@ -1,6 +1,6 @@ public IActionResult Index() { - var Order = OrderDetails.GetAllRecords(); + var Order = OrdersDetails.GetAllRecords(); ViewBag.DataSource = Order; return View(); } \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/columnmenu/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/columnmenu/razor index a5c0b6fa82..8eeb3bfcec 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/columns/columnmenu/razor +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/columnmenu/razor @@ -1,9 +1,8 @@ -@Html.EJS().Grid("ColumnMenu").DataSource((IEnumerable)ViewBag.dataSource).ShowColumnMenu(true).AllowSorting().AllowFiltering(true).AllowGrouping().Columns(col => { - - col.Field("OrderID").HeaderText("Order ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); - col.Field("CustomerID").HeaderText("Customer Name").Width("150").Add(); - col.Field("Freight").HeaderText("Freight").Width("120").Format("C2").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); - col.Field("ShipName").HeaderText("Ship Name").Width("150").Add(); - col.Field("ShipCity").HeaderText("Ship City").Width("150").Add(); - -}).FilterSettings(filter => { filter.Type(Syncfusion.EJ2.Grids.FilterType.CheckBox); }).GroupSettings(group => { group.ShowGroupedColumn(true); }).AllowPaging().Render() \ No newline at end of file + @Html.EJS().Grid("Grid").DataSource((IEnumerable)ViewBag.DataSource).ShowColumnMenu(true).AllowSorting().AllowFiltering(true).AllowGrouping().Columns(col => + { + col.Field("OrderID").HeaderText("Order ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("CustomerID").HeaderText("Customer ID").Width("120").Add(); + col.Field("Freight").HeaderText("Freight").Width("120").Format("C").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("ShipCity").HeaderText("Ship City").Width("130").Add(); + col.Field("ShipCountry").HeaderText("Ship Country").Width("130").Add(); + }).FilterSettings(filter => { filter.Type(Syncfusion.EJ2.Grids.FilterType.CheckBox); }).GroupSettings(group => { group.ShowGroupedColumn(true); }).AllowPaging().Render() diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/columnmenu/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/columnmenu/tagHelper index bed94f01ea..ec0f0574c9 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/columns/columnmenu/tagHelper +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/columnmenu/tagHelper @@ -1,11 +1,12 @@ - - - + + + - - - - - + + + + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/resizeevents/resizeevents.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/columnmenuevents/columnmenu.cs similarity index 100% rename from ej2-asp-core-mvc/code-snippet/grid/columns/resizeevents/resizeevents.cs rename to ej2-asp-core-mvc/code-snippet/grid/columns/columnmenuevents/columnmenu.cs diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/columnmenuevents/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/columnmenuevents/razor index 92906881df..426ddfcf20 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/columns/columnmenuevents/razor +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/columnmenuevents/razor @@ -1,22 +1,22 @@ +
-@Html.EJS().Grid("ColumnMenu").DataSource((IEnumerable)ViewBag.dataSource).ShowColumnMenu(true).AllowSorting().AllowFiltering(true).AllowGrouping().Columns(col => { + @Html.EJS().Grid("Grid").DataSource((IEnumerable)ViewBag.DataSource).ShowColumnMenu(true).AllowSorting().AllowFiltering(true).AllowGrouping(true).Columns(col => + { + col.Field("OrderID").HeaderText("Order ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("CustomerID").HeaderText("Customer ID").Width("120").Add(); + col.Field("Freight").HeaderText("Freight").Width("120").Format("C").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("ShipCity").HeaderText("Ship City").Width("130").Add(); + col.Field("ShipCountry").HeaderText("Ship Country").Width("130").Add(); + }).AllowPaging().ColumnMenuClick("columnMenuClick").ColumnMenuOpen("columnMenuOpen").FilterSettings(filter => { filter.Type(Syncfusion.EJ2.Grids.FilterType.CheckBox); }).GroupSettings(group => group.ShowGroupedColumn(true)).Render() - col.Field("OrderID").HeaderText("Order ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); - col.Field("CustomerID").HeaderText("Customer Name").Width("150").Add(); - col.Field("Freight").HeaderText("Freight").Width("120").Format("C2").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); - col.Field("ShipName").HeaderText("Ship Name").Width("150").Add(); - col.Field("ShipCity").HeaderText("Ship City").Width("150").Add(); + \ No newline at end of file + function columnMenuClick(args) { + + document.getElementById("message").innerText = 'columnMenuClick event is triggered'; + + } + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/columnmenuevents/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/columnmenuevents/tagHelper index 9c7b4a509a..a79f4be052 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/columns/columnmenuevents/tagHelper +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/columnmenuevents/tagHelper @@ -1,22 +1,25 @@ - - - +

+ + + + + - - - - - + + + + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/complexbinding/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/complexbinding/razor index c3ea1b2ad0..7e2e4d53e4 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/columns/complexbinding/razor +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/complexbinding/razor @@ -1,9 +1,7 @@ -@Html.EJS().Grid("Complex").DataSource((IEnumerable)ViewBag.dataSource).Columns(col => +@Html.EJS().Grid("Grid").DataSource((IEnumerable)ViewBag.data).Height(350).Columns(col => { - col.Field("EmployeeID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); - col.Field("Name.FirstName").HeaderText("FirstName").Width("140").Add(); - col.Field("Name.LastName").HeaderText("LastName").Width("130").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); - col.Field("City").Width("120").Add(); - col.Field("Country").Width("140").Add(); - -}).AllowPaging().Render() \ No newline at end of file + col.Field("EmployeeID").HeaderText("Employee ID").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Width("120").Add(); + col.Field("Name.FirstName").HeaderText("First Name").Width("120").Add(); + col.Field("Name.LastName").HeaderText("Last Name").Width("120").Add(); + col.Field("Title").HeaderText("Title").Width("150").Add(); +}).Render() diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/complexbinding/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/complexbinding/tagHelper index 1d730b1b41..23f1e7f530 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/columns/complexbinding/tagHelper +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/complexbinding/tagHelper @@ -1,8 +1,8 @@ - + - - + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/custom-column-menu-icon/columnmenu.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/custom-column-menu-icon/columnmenu.cs new file mode 100644 index 0000000000..47e5e3b61d --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/custom-column-menu-icon/columnmenu.cs @@ -0,0 +1,5 @@ +public IActionResult Index() +{ + ViewBag.DataSource = OrdersDetails.GetAllRecords(); + return View(); +} \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/custom-column-menu-icon/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/custom-column-menu-icon/razor new file mode 100644 index 0000000000..dce9561d9f --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/custom-column-menu-icon/razor @@ -0,0 +1,18 @@ + + +@Html.EJS().Grid("Grid").DataSource((IEnumerable)ViewBag.DataSource).ShowColumnMenu(true).Columns(col => +{ + col.Field("OrderID").HeaderText("Order ID").Width("120").Add(); + col.Field("CustomerID").HeaderText("Customer Name").Width("150").Add(); + col.Field("OrderDate").HeaderText("Order Date").Width("130").Format("yMd").Add(); + col.Field("Freight").HeaderText("Freight").Width("120").Format("C2").Add(); + col.Field("ShipCountry").HeaderText("Ship Country").Width("120").Add(); + + }).Render() + + + diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/custom-column-menu-icon/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/custom-column-menu-icon/tagHelper new file mode 100644 index 0000000000..345c420a4e --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/custom-column-menu-icon/tagHelper @@ -0,0 +1,16 @@ + + + + + + + + + + + + diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/customcolumnmenu/columnmenu.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/customcolumnmenu/columnmenu.cs new file mode 100644 index 0000000000..a313f00f64 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/customcolumnmenu/columnmenu.cs @@ -0,0 +1,6 @@ +public IActionResult Index() +{ + var Order = OrdersDetails.GetAllRecords(); + ViewBag.DataSource = Order; + return View(); +} \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/customcolumnmenu/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/customcolumnmenu/razor index 02c4c54550..8a00c326e2 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/columns/customcolumnmenu/razor +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/customcolumnmenu/razor @@ -2,25 +2,22 @@ List columnMenuitems = new List(); columnMenuitems.Add(new { text = "Clear Sorting", id = "gridclearsorting" }); List cols = new List(); - cols.Add(new { field = "CustomerID", direction = "Ascending" }); + cols.Add(new { field = "OrderID", direction = "Ascending" }); } - -@Html.EJS().Grid("CustomColumnMenu").DataSource((IEnumerable)ViewBag.dataSource).ShowColumnMenu(true).AllowSorting().Columns(col => -{ +@Html.EJS().Grid("Grid").DataSource((IEnumerable)ViewBag.DataSource).ShowColumnMenu(true).AllowSorting().Columns(col => + { col.Field("OrderID").HeaderText("Order ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); - col.Field("CustomerID").HeaderText("Customer Name").Width("150").Add(); - col.Field("Freight").HeaderText("Freight").Width("120").Format("C2").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); - col.Field("ShipName").HeaderText("Ship Name").Width("150").Add(); - col.Field("ShipCity").HeaderText("Ship City").Width("150").Add(); - -}).AllowPaging().SortSettings(sort => sort.Columns(cols)).ColumnMenuItems(columnMenuitems).ColumnMenuClick("columnMenuClick").ShowColumnMenu(true).Render() + col.Field("CustomerID").HeaderText("Customer ID").Width("120").Add(); + col.Field("Freight").HeaderText("Freight").Width("120").Format("C").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("ShipCity").HeaderText("Ship City").Width("130").Add(); + col.Field("ShipCountry").HeaderText("Ship Country").Width("130").Add(); + }).AllowPaging().ColumnMenuClick("columnMenuClick").SortSettings(sort => sort.Columns(cols)).ColumnMenuItems(columnMenuitems).Render() \ No newline at end of file + diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/customcolumnmenu/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/customcolumnmenu/tagHelper index 39ff7c7126..531dc8df76 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/columns/customcolumnmenu/tagHelper +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/customcolumnmenu/tagHelper @@ -1,22 +1,29 @@ -@{ +@{ + List columnMenuitems = new List(); + columnMenuitems.Add(new { text = "Clear Sorting", id = "gridclearsorting" }); + List cols = new List(); + cols.Add(new { field = "OrderID", direction = "Ascending" }); +} + + + + - List columnMenuitems = new List(); - columnMenuitems.Add(new { text = "Clear Sorting", id = "gridclearsorting" }); - } - - - - - - + + + + + \ No newline at end of file + diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/customizecolumnmenu/columnmenu.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/customizecolumnmenu/columnmenu.cs new file mode 100644 index 0000000000..a313f00f64 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/customizecolumnmenu/columnmenu.cs @@ -0,0 +1,6 @@ +public IActionResult Index() +{ + var Order = OrdersDetails.GetAllRecords(); + ViewBag.DataSource = Order; + return View(); +} \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/customizecolumnmenu/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/customizecolumnmenu/razor index ccea87fa73..a0f128a0a9 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/columns/customizecolumnmenu/razor +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/customizecolumnmenu/razor @@ -1,13 +1,11 @@ -@Html.EJS().Grid("CustomizeColumnMenu").DataSource((IEnumerable)ViewBag.dataSource).ShowColumnMenu(true).AllowSorting().AllowFiltering(true).AllowGrouping().ColumnMenuOpen("columnMenuOpen").Columns(col => +@Html.EJS().Grid("Grid").DataSource((IEnumerable)ViewBag.DataSource).ShowColumnMenu(true).AllowSorting().AllowFiltering(true).AllowGrouping(true).Columns(col => { - col.Field("OrderID").HeaderText("Order ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); - col.Field("CustomerID").HeaderText("Customer Name").Width("150").Add(); - col.Field("Freight").HeaderText("Freight").Width("120").Format("C2").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); - col.Field("ShipName").HeaderText("Ship Name").Width("150").Add(); - col.Field("ShipCity").HeaderText("Ship City").Width("150").Add(); - -}).FilterSettings(filter=> { filter.Type(Syncfusion.EJ2.Grids.FilterType.CheckBox); }).GroupSettings(group=>group.ShowGroupedColumn(true)).AllowPaging().Render() - +col.Field("OrderID").HeaderText("Order ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); +col.Field("CustomerID").HeaderText("Customer ID").Width("120").Add(); +col.Field("Freight").HeaderText("Freight").Width("120").Format("C").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); +col.Field("ShipCity").HeaderText("Ship City").Width("130").Add(); +col.Field("ShipCountry").HeaderText("Ship Country").Width("130").Add(); +}).AllowPaging().ColumnMenuOpen("columnMenuOpen").FilterSettings(filter => { filter.Type(Syncfusion.EJ2.Grids.FilterType.Menu); }).Render() + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/frozen-color/frozen.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/frozen-color/frozen.cs new file mode 100644 index 0000000000..d7ac3aa3f2 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/frozen-color/frozen.cs @@ -0,0 +1,6 @@ +public IActionResult DefaultExporting() +{ + var order = OrdersDetails.GetAllRecords(); + ViewBag.dataSource = order; + return View(); +} diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/frozen-color/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/frozen-color/razor new file mode 100644 index 0000000000..8ce48b44fd --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/frozen-color/razor @@ -0,0 +1,28 @@ +@Html.EJS().Grid("Grid").DataSource((IEnumerable)ViewBag.dataSource).Columns(col => +{ + col.Field("OrderID").HeaderText("Order ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("CustomerID").HeaderText("Customer ID").Freeze(Syncfusion.EJ2.Grids.FreezeDirection.Left).Width("130").Add(); + col.Field("Freight").HeaderText("Freight").Width("120").Format("C").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("ShipAddress").HeaderText("Ship Address").Freeze(Syncfusion.EJ2.Grids.FreezeDirection.Fixed).Width("120").Add(); + col.Field("OrderDate").HeaderText("Order Date").Width("130").Format("yMd").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("ShipName").HeaderText("Ship Name").Width("120").Add(); + col.Field("ShipCity").HeaderText("Ship City").Width("120").Add(); + col.Field("ShipCountry").HeaderText("Ship Country").Freeze(Syncfusion.EJ2.Grids.FreezeDirection.Right).Width("120").Add(); +}).Render() + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/frozen-color/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/frozen-color/tagHelper new file mode 100644 index 0000000000..65ec06d872 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/frozen-color/tagHelper @@ -0,0 +1,29 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/frozen-columns/frozen.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/frozen-columns/frozen.cs new file mode 100644 index 0000000000..d7ac3aa3f2 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/frozen-columns/frozen.cs @@ -0,0 +1,6 @@ +public IActionResult DefaultExporting() +{ + var order = OrdersDetails.GetAllRecords(); + ViewBag.dataSource = order; + return View(); +} diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/frozen-columns/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/frozen-columns/razor new file mode 100644 index 0000000000..876ce8ed08 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/frozen-columns/razor @@ -0,0 +1,23 @@ + +@Html.EJS().NumericTextBox("frozenColumns").Min('0').Max('3').Width("100").Format("n").Value(2).ValidateDecimalOnType(true).Decimals(3).Render() +@Html.EJS().Button("button").Content("Update").Render() +@Html.EJS().Grid("Grid").FrozenColumns(2).DataSource((IEnumerable)ViewBag.dataSource).Columns(col => +{ + col.Field("OrderID").HeaderText("Order ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("CustomerID").HeaderText("Customer ID").Width("130").Add(); + col.Field("EmployeeID").HeaderText("Employee ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("Freight").HeaderText("Freight").Width("120").Format("C").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("OrderDate").HeaderText("Order Date").Width("130").Format("yMd").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("ShipCountry").HeaderText("Ship Country").Width("120").Add(); + col.Field("ShipCity").HeaderText("Ship City").Width("120").Add(); + col.Field("ShipAddress").HeaderText("Ship Address").Width("120").Add(); + col.Field("ShipName").HeaderText("Ship Name").Width("120").Add(); +}).Render() + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/frozen-columns/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/frozen-columns/tagHelper new file mode 100644 index 0000000000..998cf9a6b8 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/frozen-columns/tagHelper @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/frozen-direction/frozen.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/frozen-direction/frozen.cs new file mode 100644 index 0000000000..d782bae97c --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/frozen-direction/frozen.cs @@ -0,0 +1,9 @@ +public IActionResult DefaultExporting() +{ + var order = OrdersDetails.GetAllRecords(); + ViewBag.dataSource = order; + ViewBag.dropdownData = new string[] { "OrderID", "CustomerID", "Freight", "OrderDate", "ShipCountry", "ShipCity", "ShipAddress", "ShipName" }; + ViewBag.directionData = new string[] {"Left","Right","Fixed" }; + + return View(); +} diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/frozen-direction/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/frozen-direction/razor new file mode 100644 index 0000000000..9b9f4fae15 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/frozen-direction/razor @@ -0,0 +1,35 @@ +
+ + + @Html.EJS().DropDownList("columnDropDown").Index(4).Width("180px").DataSource(@ViewBag.dropdownData).Render() + +
+
+ + + @Html.EJS().DropDownList("directionDropDown").Index(0).Width("180px").DataSource(@ViewBag.directionData).Render() + +
+ @Html.EJS().Button("button").Content("Update").Render() +
+
+ +@Html.EJS().Grid("Grid").DataSource((IEnumerable)ViewBag.dataSource).Columns(col => +{ + col.Field("OrderID").HeaderText("Order ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("Freight").HeaderText("Freight").Freeze(Syncfusion.EJ2.Grids.FreezeDirection.Fixed).Width("120").Format("C").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("CustomerID").HeaderText("Customer ID").Freeze(Syncfusion.EJ2.Grids.FreezeDirection.Right).Width("130").Add(); + col.Field("OrderDate").HeaderText("Order Date").Width("130").Format("yMd").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("ShipName").HeaderText("Ship Name").Width("120").Add(); + col.Field("ShipAddress").HeaderText("Ship Address").Width("120").Add(); + col.Field("ShipCity").HeaderText("Ship City").Width("120").Add(); +col.Field("ShipCountry").HeaderText("Ship Country").Freeze(Syncfusion.EJ2.Grids.FreezeDirection.Left).Width("120").Add(); +}).Render() + + diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/frozen-direction/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/frozen-direction/tagHelper new file mode 100644 index 0000000000..267c018f97 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/frozen-direction/tagHelper @@ -0,0 +1,36 @@ +
+ + + + +
+
+ + + + +
+ +
+
+ + + + + + + + + + + + + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/frozen-particular/frozen.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/frozen-particular/frozen.cs new file mode 100644 index 0000000000..bdcc7dd630 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/frozen-particular/frozen.cs @@ -0,0 +1,7 @@ +public IActionResult DefaultExporting() +{ + var order = OrdersDetails.GetAllRecords(); + ViewBag.dropdownData = new string[] { "OrderID", "CustomerID", "EmployeeID", "Freight", "OrderDate", "ShipCountry", "ShipCity", "ShipAddress", "ShipName" }; + ViewBag.dataSource = order; + return View(); +} diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/frozen-particular/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/frozen-particular/razor new file mode 100644 index 0000000000..d0629207a3 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/frozen-particular/razor @@ -0,0 +1,37 @@ +
+ + + @Html.EJS().DropDownList("dropdown").Index(1).Width("180px").DataSource(@ViewBag.dropdownData).Change("columnChange").Render() + +
+@Html.EJS().Grid("Grid").DataSource((IEnumerable)ViewBag.dataSource).Columns(col => +{ + col.Field("OrderID").HeaderText("Order ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("CustomerID").HeaderText("Customer ID").IsFrozen(true).Width("130").Add(); + col.Field("EmployeeID").HeaderText("Employee ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("Freight").HeaderText("Freight").Width("120").Format("C").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("OrderDate").HeaderText("Order Date").Width("130").Format("yMd").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("ShipCountry").HeaderText("Ship Country").Width("120").Add(); + col.Field("ShipCity").HeaderText("Ship City").Width("120").Add(); + col.Field("ShipAddress").HeaderText("Ship Address").Width("120").Add(); + col.Field("ShipName").HeaderText("Ship Name").Width("120").Add(); +}).Render() + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/frozen-particular/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/frozen-particular/tagHelper new file mode 100644 index 0000000000..8d7a100008 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/frozen-particular/tagHelper @@ -0,0 +1,38 @@ +
+ + + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/headertemplate/headertemplate.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/headertemplate/headertemplate.cs index 62440176fe..17bfdc3653 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/columns/headertemplate/headertemplate.cs +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/headertemplate/headertemplate.cs @@ -1,6 +1,6 @@ public IActionResult Index() { - var Emp = EmployeeDetails.GetAllRecords(); - ViewBag.DataSource = Emp; - return View(); -} \ No newline at end of file + var orders = OrdersDetails.GetAllRecords(); + ViewBag.DataSource = orders; + return View(); +} \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/headertemplate/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/headertemplate/razor index dec2bb2f80..7bb1c4d30f 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/columns/headertemplate/razor +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/headertemplate/razor @@ -1,31 +1,75 @@ -@Html.EJS().Grid("HeaderTemplate").DataSource((IEnumerable)ViewBag.dataSource).Columns(col => +@Html.EJS().Grid("Grid").DataSource((IEnumerable)ViewBag.DataSource).Columns(col => { - col.Field("EmployeeID").HeaderTemplate("#employeetemplate").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); - col.Field("FirstName").Width("140").Add(); - col.Field("BirthDate").HeaderTemplate("#datetemplate").Width("130").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); - col.Field("City").Width("120").Add(); - col.Field("Country").Width("140").Add(); - -}).AllowPaging().Render() - + col.Field("OrderID").HeaderText("Order ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("CustomerID").HeaderText("Customer ID").Width("140").HeaderTemplate("#customerTemplate").Add(); + col.Field("Freight").HeaderText("Freight").Width("120").HeaderTemplate("#freightTemplate").Format("C").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("OrderDate").HeaderText("Order Date").Width("140").HeaderTemplate("#datetemplate").Format("yMd").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); +}).HeaderCellInfo("onHeaderCellInfo").Render() + .e-icon-userlogin::before { + font-family: 'ej2-headertemplate'; + content: "\e702"; + } + + + - \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/headertemplate/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/headertemplate/tagHelper index 37c784bc56..e9b4787a70 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/columns/headertemplate/tagHelper +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/headertemplate/tagHelper @@ -1,29 +1,72 @@ - + - - - - - + + + + - + .e-icon-userlogin::before { + font-family: 'ej2-headertemplate'; + content: "\e702"; + } + - + + + - \ No newline at end of file + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-autowrap/headertext.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-autowrap/headertext.cs new file mode 100644 index 0000000000..76029d8c4a --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-autowrap/headertext.cs @@ -0,0 +1,7 @@ +public IActionResult Index() +{ + var Order = InventoryDetails.GetAllRecords(); + ViewBag.DataSource = Order; + ViewBag.dropdownData = new string[] { "Header", "Both" }; + return View(); +} \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-autowrap/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-autowrap/razor new file mode 100644 index 0000000000..0e2f4d9211 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-autowrap/razor @@ -0,0 +1,21 @@ +
+ + + @Html.EJS().DropDownList("Wrap").Index(0).Width("180px").DataSource(@ViewBag.dropdownData).Change("valueChange").Render() + +
+@Html.EJS().Grid("Grid").DataSource((IEnumerable)ViewBag.DataSource).AllowTextWrap().Columns(col => +{ + col.Field("Inventor").HeaderText("Inventor Name").Width("130").Add(); + col.Field("NumberOfPatentFamilies").HeaderText("Number of Patent Families").Width("150").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("Country").HeaderText("Country").Width("100").Add(); + col.Field("Active").HeaderText("Active").Width("100").Add(); + col.Field("Mainfieldsofinvention").HeaderText("Main Fields Of Invention").Width("150").Add(); +}).TextWrapSettings(text => { text.WrapMode(Syncfusion.EJ2.Grids.WrapMode.Header); }).Render() + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-autowrap/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-autowrap/tagHelper new file mode 100644 index 0000000000..19581f9017 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-autowrap/tagHelper @@ -0,0 +1,23 @@ +
+ + + + +
+ + + + + + + + + + + + diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-change-all/columntext.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-change-all/columntext.cs new file mode 100644 index 0000000000..17bfdc3653 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-change-all/columntext.cs @@ -0,0 +1,6 @@ +public IActionResult Index() +{ + var orders = OrdersDetails.GetAllRecords(); + ViewBag.DataSource = orders; + return View(); +} \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-change-all/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-change-all/razor new file mode 100644 index 0000000000..a0ac706b5a --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-change-all/razor @@ -0,0 +1,28 @@ +
+ @Html.EJS().Button("buttons").Content("Change Header Text").Render() +
+@Html.EJS().Grid("Grid").DataSource((IEnumerable)ViewBag.DataSource).Columns(col => +{ + col.Field("OrderID").HeaderText("Order ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("CustomerID").HeaderText("Customer ID").Width("130").Add(); + col.Field("Freight").HeaderText("Freight").Width("120").Format("C").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("OrderDate").HeaderText("Order Date").Width("130").Format("yMd").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("ShipCountry").HeaderText("Ship Country").Width("120").Add(); +}).Render() + + + diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-change-all/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-change-all/tagHelper new file mode 100644 index 0000000000..7b1c05d438 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-change-all/tagHelper @@ -0,0 +1,30 @@ +
+ + +
+ + + + + + + + + + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-change-height/headertext.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-change-height/headertext.cs new file mode 100644 index 0000000000..17bfdc3653 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-change-height/headertext.cs @@ -0,0 +1,6 @@ +public IActionResult Index() +{ + var orders = OrdersDetails.GetAllRecords(); + ViewBag.DataSource = orders; + return View(); +} \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-change-height/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-change-height/razor new file mode 100644 index 0000000000..a3132d9992 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-change-height/razor @@ -0,0 +1,34 @@ +
+ @Html.EJS().Button("small").Content("Change height 20px").Render() + @Html.EJS().Button("medium").Content("Default height 42px").Render() + @Html.EJS().Button("big").Content("Change height 60px").Render() +
+
+ @Html.EJS().Grid("Grid").DataSource((IEnumerable)ViewBag.DataSource).Columns(col => + { + col.Field("OrderID").HeaderText("Order ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("CustomerID").HeaderText("Customer ID").Width("130").Add(); + col.Field("Freight").HeaderText("Freight").Width("120").Format("C").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("OrderDate").HeaderText("Order Date").Width("130").Format("yMd").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("ShipCountry").HeaderText("Ship Country").Width("120").Add(); + }).Render() + + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-change-height/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-change-height/tagHelper new file mode 100644 index 0000000000..fd78af6c13 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-change-height/tagHelper @@ -0,0 +1,36 @@ +
+ + + +
+
+ + + + + + + + + +
+ + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-change/columntext.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-change/columntext.cs new file mode 100644 index 0000000000..0899739419 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-change/columntext.cs @@ -0,0 +1,7 @@ +public IActionResult Index() +{ + var orders = OrdersDetails.GetAllRecords(); + ViewBag.DataSource = orders; + ViewBag.dropdownData = new string[] { "OrderID", "CustomerID", "Freight", "OrderDate","ShipCountry" }; + return View(); +} \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-change/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-change/razor new file mode 100644 index 0000000000..e7b051dd1b --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-change/razor @@ -0,0 +1,34 @@ +
+ + + @Html.EJS().DropDownList("dropdown").Index(0).Width("180px").DataSource(@ViewBag.dropdownData).Render() + +
+
+ + @Html.EJS().TextBox("textbox").Placeholder("Enter new header text").Width("220px").Render() + @Html.EJS().Button("buttons").Content("Change").Render() +
+ +@Html.EJS().Grid("Grid").DataSource((IEnumerable)ViewBag.DataSource).Columns(col => +{ + col.Field("OrderID").HeaderText("Order ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("CustomerID").HeaderText("Customer ID").Width("130").Add(); + col.Field("Freight").HeaderText("Freight").Width("120").Format("C").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("OrderDate").HeaderText("Order Date").Width("130").Format("yMd").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("ShipCountry").HeaderText("Ship Country").Width("120").Add(); +}).AllowPaging().Render() + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-change/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-change/tagHelper new file mode 100644 index 0000000000..549f988332 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-change/tagHelper @@ -0,0 +1,37 @@ +
+ + + + +
+
+ + + + + +
+ + + + + + + + + + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-orientation/headertext.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-orientation/headertext.cs new file mode 100644 index 0000000000..17bfdc3653 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-orientation/headertext.cs @@ -0,0 +1,6 @@ +public IActionResult Index() +{ + var orders = OrdersDetails.GetAllRecords(); + ViewBag.DataSource = orders; + return View(); +} \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-orientation/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-orientation/razor new file mode 100644 index 0000000000..38c07e16df --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-orientation/razor @@ -0,0 +1,23 @@ +@Html.EJS().Grid("Grid").DataSource((IEnumerable)ViewBag.DataSource).Columns(col => +{ + col.Field("OrderID").HeaderText("Order ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("CustomerID").HeaderText("Customer ID").Width("130").Add(); + col.Field("Freight").HeaderText("Freight").Width("120").Format("C").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Center).CustomAttributes(new { @class = "orientationcss" }).Add(); + col.Field("OrderDate").HeaderText("Order Date").Width("130").Format("yMd").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("ShipCity").HeaderText("Ship City").Width("120").Add(); +}).Created("setHeaderHeight").Render() + + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-orientation/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-orientation/tagHelper new file mode 100644 index 0000000000..64393d4224 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-orientation/tagHelper @@ -0,0 +1,24 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-refresh/headertext.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-refresh/headertext.cs new file mode 100644 index 0000000000..17bfdc3653 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-refresh/headertext.cs @@ -0,0 +1,6 @@ +public IActionResult Index() +{ + var orders = OrdersDetails.GetAllRecords(); + ViewBag.DataSource = orders; + return View(); +} \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-refresh/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-refresh/razor new file mode 100644 index 0000000000..479fc970ea --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-refresh/razor @@ -0,0 +1,21 @@ +@Html.EJS().Button("button").Content("Refresh Header").Render() +
+ + @Html.EJS().Grid("Grid").DataSource((IEnumerable)ViewBag.DataSource).Columns(col => + { + col.Field("OrderID").HeaderText("Order ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("CustomerID").HeaderText("Customer ID").Width("130").Add(); + col.Field("Freight").HeaderText("Freight").Width("120").Format("C").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("OrderDate").HeaderText("Order Date").Width("130").Format("yMd").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("ShipCountry").HeaderText("Ship Country").Width("120").Add(); + }).Render() + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-refresh/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-refresh/tagHelper new file mode 100644 index 0000000000..5cbcac8b10 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-refresh/tagHelper @@ -0,0 +1,21 @@ + +
+ + + + + + + + + +
+ \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-stacked/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-stacked/razor new file mode 100644 index 0000000000..d8388dd5e0 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-stacked/razor @@ -0,0 +1,58 @@ + + +@Html.EJS().Grid("Grid").DataSource((IEnumerable)ViewBag.DataSource).Columns(col => +{ + col.Field("OrderID").HeaderText("Order ID").Width("120").HeaderTemplate("#orderIDTemplate").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.HeaderText("Order Details").HeaderTemplate("#orderDetailsTemplate").Columns(new List() { new Syncfusion.EJ2.Grids.GridColumn { Field = "OrderDate",HeaderTemplate= "#datetemplate", Width = "135", HeaderText = "Order Date",TextAlign=Syncfusion.EJ2.Grids.TextAlign.Right,Format="yMd", MinWidth="10" }, + new Syncfusion.EJ2.Grids.GridColumn { Field = "Freight", Width = "130", TextAlign=Syncfusion.EJ2.Grids.TextAlign.Right, HeaderText = "Freight($)", Format="C2", MinWidth="10"} }).Add(); + col.HeaderText("Shipped Details").HeaderTemplate("#shipDetailsTemplate").Columns(new List() { new Syncfusion.EJ2.Grids.GridColumn { Field = "ShippedDate", Width = "140", HeaderText = "Shipped Date", TextAlign=Syncfusion.EJ2.Grids.TextAlign.Right, Format = "yMd", MinWidth="10" }, + new Syncfusion.EJ2.Grids.GridColumn { Field = "ShipCountry", Width = "145", HeaderText = "Ship Country", MinWidth="10", EditType="dropdownedit" } }).Add(); +}).HeaderCellInfo("onHeaderCellInfo").Render() + + + + + + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-stacked/stackedHeader.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-stacked/stackedHeader.cs new file mode 100644 index 0000000000..7bee9f9efa --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-stacked/stackedHeader.cs @@ -0,0 +1,6 @@ +public IActionResult Index() +{ + var orders = OrdersDetails.GetAllRecords(); + ViewBag.DataSource= orders; + return View(); +} \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-stacked/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-stacked/tagHelper new file mode 100644 index 0000000000..3707b4fad0 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-stacked/tagHelper @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-textalign/headertext.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-textalign/headertext.cs new file mode 100644 index 0000000000..f9f98c90cb --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-textalign/headertext.cs @@ -0,0 +1,7 @@ +public IActionResult Index() +{ + var orders = OrdersDetails.GetAllRecords(); + ViewBag.DataSource = orders; + ViewBag.dropdownData = new string[] { "Left", "Right", "Center", "Justify"}; + return View(); +} \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-textalign/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-textalign/razor new file mode 100644 index 0000000000..a345da7aab --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-textalign/razor @@ -0,0 +1,23 @@ +
+ + + @Html.EJS().DropDownList("dropdown").Width("180px").Index(0).DataSource(@ViewBag.dropdownData).Change("changeAlignment").Render() + +
+@Html.EJS().Grid("Grid").DataSource((IEnumerable)ViewBag.DataSource).Columns(col => +{ + col.Field("OrderID").HeaderText("Order ID").Width("120").Add(); + col.Field("CustomerID").HeaderText("Customer ID").Width("140").Add(); + col.Field("Freight").HeaderText("Freight").Width("120").Format("C").Add(); + col.Field("OrderDate").HeaderText("Order Date").Width("140").Format("yMd").Add(); +}).Render() + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-textalign/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-textalign/tagHelper new file mode 100644 index 0000000000..63a11919e3 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-textalign/tagHelper @@ -0,0 +1,23 @@ +
+ + + + +
+ + + + + + + + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-tooltip/headertext.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-tooltip/headertext.cs new file mode 100644 index 0000000000..17bfdc3653 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-tooltip/headertext.cs @@ -0,0 +1,6 @@ +public IActionResult Index() +{ + var orders = OrdersDetails.GetAllRecords(); + ViewBag.DataSource = orders; + return View(); +} \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-tooltip/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-tooltip/razor new file mode 100644 index 0000000000..5e2c9dc15e --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-tooltip/razor @@ -0,0 +1,27 @@ +@Html.EJS().Tooltip("tooltip").Target(".e-headertext").Position(Syncfusion.EJ2.Popups.Position.TopCenter).ContentTemplate(@
+ @Html.EJS().Grid("Grid").DataSource((IEnumerable)ViewBag.DataSource).Columns(col => + { + col.Field("OrderID").HeaderText("Order ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("Freight").HeaderText("Freight").Width("120").Format("C").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("ShipName").HeaderText("Ship Name").Width("120").Add(); + col.Field("OrderDate").HeaderText("Order Date").Width("130").Format("yMd").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("ShipCountry").HeaderText("Ship Country").Width("120").Add(); + }).Render() +).BeforeRender("beforeRender").Render() + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-tooltip/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-tooltip/tagHelper new file mode 100644 index 0000000000..e33d9e32a7 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-tooltip/tagHelper @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-using-css/headertext.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-using-css/headertext.cs new file mode 100644 index 0000000000..17bfdc3653 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-using-css/headertext.cs @@ -0,0 +1,6 @@ +public IActionResult Index() +{ + var orders = OrdersDetails.GetAllRecords(); + ViewBag.DataSource = orders; + return View(); +} \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-using-css/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-using-css/razor new file mode 100644 index 0000000000..c6087aa71e --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-using-css/razor @@ -0,0 +1,14 @@ +@Html.EJS().Grid("Grid").DataSource((IEnumerable)ViewBag.DataSource).Columns(col => +{ + col.Field("OrderID").HeaderText("Order ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("CustomerID").HeaderText("Customer ID").Width("130").Add(); + col.Field("Freight").HeaderText("Freight").Width("120").Format("C").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("OrderDate").HeaderText("Order Date").Width("130").Format("yMd").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("ShipCountry").HeaderText("Ship Country").Width("120").Add(); +}).Render() + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-using-css/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-using-css/tagHelper new file mode 100644 index 0000000000..391599e9ae --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-using-css/tagHelper @@ -0,0 +1,15 @@ + + + + + + + + + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-using-event/headertext.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-using-event/headertext.cs new file mode 100644 index 0000000000..17bfdc3653 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-using-event/headertext.cs @@ -0,0 +1,6 @@ +public IActionResult Index() +{ + var orders = OrdersDetails.GetAllRecords(); + ViewBag.DataSource = orders; + return View(); +} \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-using-event/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-using-event/razor new file mode 100644 index 0000000000..a172ab0eb0 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-using-event/razor @@ -0,0 +1,21 @@ +@Html.EJS().Grid("Grid").DataSource((IEnumerable)ViewBag.DataSource).Columns(col => +{ + col.Field("OrderID").HeaderText("Order ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("CustomerID").HeaderText("Customer ID").Width("130").Add(); + col.Field("Freight").HeaderText("Freight").Width("120").Format("C").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("OrderDate").HeaderText("Order Date").Width("130").Format("yMd").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("ShipCountry").HeaderText("Ship Country").Width("120").Add(); +}).HeaderCellInfo("onHeaderCellInfo").Render() + + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-using-event/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-using-event/tagHelper new file mode 100644 index 0000000000..bdaf4acf36 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-using-event/tagHelper @@ -0,0 +1,21 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-using-method/headertext.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-using-method/headertext.cs new file mode 100644 index 0000000000..17bfdc3653 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-using-method/headertext.cs @@ -0,0 +1,6 @@ +public IActionResult Index() +{ + var orders = OrdersDetails.GetAllRecords(); + ViewBag.DataSource = orders; + return View(); +} \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-using-method/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-using-method/razor new file mode 100644 index 0000000000..ba416163c1 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-using-method/razor @@ -0,0 +1,24 @@ +@Html.EJS().Grid("Grid").DataSource((IEnumerable)ViewBag.DataSource).Columns(col => +{ + col.Field("OrderID").HeaderText("Order ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("CustomerID").HeaderText("Customer ID").Width("130").Add(); + col.Field("Freight").HeaderText("Freight").Width("120").Format("C").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("ShipCountry").HeaderText("Ship Country").Width("120").Add(); +}).DataBound("dataBound").Render() + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-using-method/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-using-method/tagHelper new file mode 100644 index 0000000000..76a5b36f05 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-using-method/tagHelper @@ -0,0 +1,23 @@ + + + + + + + + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-using-property/headertext.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-using-property/headertext.cs new file mode 100644 index 0000000000..17bfdc3653 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-using-property/headertext.cs @@ -0,0 +1,6 @@ +public IActionResult Index() +{ + var orders = OrdersDetails.GetAllRecords(); + ViewBag.DataSource = orders; + return View(); +} \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-using-property/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-using-property/razor new file mode 100644 index 0000000000..e2e9bb36c0 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-using-property/razor @@ -0,0 +1,18 @@ +@Html.EJS().Grid("Grid").DataSource((IEnumerable)ViewBag.DataSource).Columns(col => +{ + col.Field("OrderID").HeaderText("Order ID").CustomAttributes(new { @class = "customcss" }).Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("CustomerID").HeaderText("Customer ID").Width("130").Add(); + col.Field("Freight").HeaderText("Freight").Width("120").CustomAttributes(new { @class = "customcss" }).Format("C").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("OrderDate").HeaderText("Order Date").Width("130").Format("yMd").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("ShipCountry").HeaderText("Ship Country").CustomAttributes(new { @class = "customcss" }).Width("120").Add(); +}).Render() + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-using-property/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-using-property/tagHelper new file mode 100644 index 0000000000..51b2f29bf5 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext-using-property/tagHelper @@ -0,0 +1,18 @@ + + + + + + + + + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/headertext/headertext.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext/headertext.cs index 62440176fe..27e57a554b 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/columns/headertext/headertext.cs +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext/headertext.cs @@ -1,6 +1,7 @@ public IActionResult Index() { - var Emp = EmployeeDetails.GetAllRecords(); - ViewBag.DataSource = Emp; + var Order = OrdersDetails.GetAllRecords(); + ViewBag.DataSource = Order; return View(); -} \ No newline at end of file +} + diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/headertext/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext/razor index e8f5740e7a..e6287cd6f6 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/columns/headertext/razor +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext/razor @@ -1,9 +1,7 @@ -@Html.EJS().Grid("HeaderText").DataSource((IEnumerable)ViewBag.dataSource).Columns(col => +@Html.EJS().Grid("HeaderText").DataSource((IEnumerable)ViewBag.DataSource).Columns(col => { - col.Field("EmployeeID").HeaderText("Employee ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); - col.Field("FirstName").HeaderText("First Name").Width("140").Add(); - col.Field("BirthDate").HeaderText("Birth Date").Format("yMd").Width("130").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); - col.Field("City").Width("120").Add(); - col.Field("Country").HeaderText("Country").Width("140").Add(); - -}).AllowPaging().Render() \ No newline at end of file + col.Field("OrderID").HeaderText("Order ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("CustomerID").HeaderText("Customer ID").Width("140").Add(); + col.Field("Freight").HeaderText("Freight").Format("yMd").Width("120").Format("C").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("OrderDate").HeaderText("Order Date").Width("140").Format("yMd").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); +}).Render() \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/headertext/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext/tagHelper index a243b9f449..b38e02948b 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/columns/headertext/tagHelper +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/headertext/tagHelper @@ -1,9 +1,8 @@ - - - - - + + + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/primary/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/primary/tagHelper deleted file mode 100644 index 778cf1e37f..0000000000 --- a/ej2-asp-core-mvc/code-snippet/grid/columns/primary/tagHelper +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/reorder-field/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/reorder-field/razor new file mode 100644 index 0000000000..40d766ac87 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/reorder-field/razor @@ -0,0 +1,31 @@ +
+ @Html.EJS().Button("reordersingle").CssClass("e-info").Content("Reorder single column").Render() + @Html.EJS().Button("reordermultiple").CssClass("e-info").Content("Reorder mutiple columns").Render() +
+@Html.EJS().Grid("Grid").DataSource((IEnumerable)ViewBag.DataSource).AllowReordering().Columns(col => +{ + col.Field("OrderID").HeaderText("Order ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("CustomerID").HeaderText("Customer ID").Width("100").Add(); + col.Field("Freight").HeaderText("Freight").Width("120").Format("C").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("ShipName").HeaderText("Ship Name").Width("130").Add(); + col.Field("ShipCity").HeaderText("Ship City").Width("130").Add(); + col.Field("ShipCountry").HeaderText("Ship Country").Width("130").Add(); +}).Render() + + + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/reorder-field/reorder.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/reorder-field/reorder.cs new file mode 100644 index 0000000000..a313f00f64 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/reorder-field/reorder.cs @@ -0,0 +1,6 @@ +public IActionResult Index() +{ + var Order = OrdersDetails.GetAllRecords(); + ViewBag.DataSource = Order; + return View(); +} \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/reorder-field/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/reorder-field/tagHelper new file mode 100644 index 0000000000..7472af37f1 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/reorder-field/tagHelper @@ -0,0 +1,31 @@ +
+ + +
+ + + + + + + + + + + + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/reorder-prevent/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/reorder-prevent/razor new file mode 100644 index 0000000000..27e6864f97 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/reorder-prevent/razor @@ -0,0 +1,8 @@ +@Html.EJS().Grid("Grid").DataSource((IEnumerable)ViewBag.DataSource).AllowReordering().Columns(col => +{ + col.Field("OrderID").HeaderText("Order ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("CustomerID").HeaderText("Customer ID").Width("120").Add(); + col.Field("Freight").HeaderText("Freight").Width("120").Format("C").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("ShipName").HeaderText("Ship Name").Width("130").AllowReordering(false).Add(); + col.Field("ShipCity").HeaderText("Ship City").Width("130").Add(); +}).Render() \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/reorder-prevent/reorder.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/reorder-prevent/reorder.cs new file mode 100644 index 0000000000..a313f00f64 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/reorder-prevent/reorder.cs @@ -0,0 +1,6 @@ +public IActionResult Index() +{ + var Order = OrdersDetails.GetAllRecords(); + ViewBag.DataSource = Order; + return View(); +} \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/reorder-prevent/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/reorder-prevent/tagHelper new file mode 100644 index 0000000000..882c8a4f94 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/reorder-prevent/tagHelper @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/reorder/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/reorder/razor index 34ac655ad1..3f2aa56c56 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/columns/reorder/razor +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/reorder/razor @@ -1,8 +1,8 @@ -@Html.EJS().Grid("Reorder").DataSource((IEnumerable)ViewBag.dataSource).AllowReordering().Columns(col => +@Html.EJS().Grid("Grid").DataSource((IEnumerable)ViewBag.DataSource).AllowReordering().Columns(col => { - col.Field("EmployeeID").HeaderText("Employee ID").Width("125").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); - col.Field("FirstName").HeaderText("Name").Width("125").Add(); - col.Field("Title").HeaderText("Title").Width("190").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); - col.Field("HireDate").HeaderText("Hire Date").Width("135").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Format("yMd").Add(); - + col.Field("OrderID").HeaderText("Order ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("CustomerID").HeaderText("Customer ID").Width("100").Add(); + col.Field("Freight").HeaderText("Freight").Width("120").Format("C").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("OrderDate").HeaderText("Order Date").Width("120").Format("yMd").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("ShipCountry").HeaderText("Ship Country").Width("130").Add(); }).Render() \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/reorder/reorder.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/reorder/reorder.cs index 62440176fe..a313f00f64 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/columns/reorder/reorder.cs +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/reorder/reorder.cs @@ -1,6 +1,6 @@ public IActionResult Index() { - var Emp = EmployeeDetails.GetAllRecords(); - ViewBag.DataSource = Emp; + var Order = OrdersDetails.GetAllRecords(); + ViewBag.DataSource = Order; return View(); } \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/reorder/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/reorder/tagHelper index 4702b77d7e..42fe9cd61d 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/columns/reorder/tagHelper +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/reorder/tagHelper @@ -1,8 +1,9 @@ - + - - - - + + + + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/reordercols/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/reordercols/razor index 67e32e07f4..276e6d4c5c 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/columns/reordercols/razor +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/reordercols/razor @@ -1,19 +1,17 @@ -@Html.EJS().Button("ReorderSingleCols").Content("Reorder Name Column to Last").Render() - -@Html.EJS().Grid("Grid").DataSource((IEnumerable)ViewBag.dataSource).AllowReordering().Columns(col => - { - col.Field("EmployeeID").HeaderText("Employee ID").Width("125").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); - col.Field("FirstName").HeaderText("Name").Width("125").Add(); - col.Field("City").HeaderText("City").Width("190").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); - col.Field("Country").HeaderText("Country").Width("135").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); - - }).Render() - - \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/reordercols/reorder.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/reordercols/reorder.cs new file mode 100644 index 0000000000..a313f00f64 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/reordercols/reorder.cs @@ -0,0 +1,6 @@ +public IActionResult Index() +{ + var Order = OrdersDetails.GetAllRecords(); + ViewBag.DataSource = Order; + return View(); +} \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/reordercols/reordercols.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/reordercols/reordercols.cs deleted file mode 100644 index 62440176fe..0000000000 --- a/ej2-asp-core-mvc/code-snippet/grid/columns/reordercols/reordercols.cs +++ /dev/null @@ -1,6 +0,0 @@ -public IActionResult Index() -{ - var Emp = EmployeeDetails.GetAllRecords(); - ViewBag.DataSource = Emp; - return View(); -} \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/reordercols/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/reordercols/tagHelper index 518689c39d..d8d4049de0 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/columns/reordercols/tagHelper +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/reordercols/tagHelper @@ -1,18 +1,19 @@ - - +
+ +
+ + - - - - + + + + + - - \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/reordercolumns/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/reordercolumns/razor deleted file mode 100644 index 4a12732149..0000000000 --- a/ej2-asp-core-mvc/code-snippet/grid/columns/reordercolumns/razor +++ /dev/null @@ -1,19 +0,0 @@ -@Html.EJS().Button("ReorderMultipleCols").Content("Reorder Name and City to Last").Render() - -@Html.EJS().Grid("Grid").DataSource((IEnumerable)ViewBag.dataSource).AllowReordering().Columns(col => -{ - col.Field("EmployeeID").HeaderText("Employee ID").Width("125").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); - col.Field("FirstName").HeaderText("Name").Width("125").Add(); - col.Field("City").HeaderText("City").Width("190").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); - col.Field("Country").HeaderText("Country").Width("135").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); - -}).Render() - - diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/reordercolumns/reordercols.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/reordercolumns/reordercols.cs deleted file mode 100644 index 62440176fe..0000000000 --- a/ej2-asp-core-mvc/code-snippet/grid/columns/reordercolumns/reordercols.cs +++ /dev/null @@ -1,6 +0,0 @@ -public IActionResult Index() -{ - var Emp = EmployeeDetails.GetAllRecords(); - ViewBag.DataSource = Emp; - return View(); -} \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/reordercolumns/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/reordercolumns/tagHelper deleted file mode 100644 index 5f5b1d3b58..0000000000 --- a/ej2-asp-core-mvc/code-snippet/grid/columns/reordercolumns/tagHelper +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/reorderevents/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/reorderevents/razor index 326efa9cf2..00b924620a 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/columns/reorderevents/razor +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/reorderevents/razor @@ -1,22 +1,36 @@ -@Html.EJS().Grid("Reorder").DataSource((IEnumerable)ViewBag.dataSource).AllowReordering().Columns(col => -{ - col.Field("EmployeeID").HeaderText("Employee ID").Width("125").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); - col.Field("FirstName").HeaderText("Name").Width("125").Add(); - col.Field("City").HeaderText("City").Width("190").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); - col.Field("Country").HeaderText("Country").Width("135").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); - -}).ColumnDragStart("columnDragStart").ColumnDrag("columnDrag").ColumnDrop("columnDrop").Render() - - \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/reorderevents/reorder.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/reorderevents/reorder.cs new file mode 100644 index 0000000000..a313f00f64 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/reorderevents/reorder.cs @@ -0,0 +1,6 @@ +public IActionResult Index() +{ + var Order = OrdersDetails.GetAllRecords(); + ViewBag.DataSource = Order; + return View(); +} \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/reorderevents/reorderevents.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/reorderevents/reorderevents.cs deleted file mode 100644 index 62440176fe..0000000000 --- a/ej2-asp-core-mvc/code-snippet/grid/columns/reorderevents/reorderevents.cs +++ /dev/null @@ -1,6 +0,0 @@ -public IActionResult Index() -{ - var Emp = EmployeeDetails.GetAllRecords(); - ViewBag.DataSource = Emp; - return View(); -} \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/reorderevents/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/reorderevents/tagHelper index 39de39d1aa..a1caed1edb 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/columns/reorderevents/tagHelper +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/reorderevents/tagHelper @@ -1,23 +1,41 @@ - +

+ + - - - - + + + + + + - \ No newline at end of file + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/reordertargetcolumns/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/reordertargetcolumns/razor new file mode 100644 index 0000000000..f1568cf0a8 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/reordertargetcolumns/razor @@ -0,0 +1,28 @@ +
+ @Html.EJS().Button("reordersingle").CssClass("e-info").Content("Reorder single column").Render() + @Html.EJS().Button("reordermultiple").CssClass("e-info").Content("Reorder mutiple columns").Render() +
+@Html.EJS().Grid("Grid").DataSource((IEnumerable)ViewBag.DataSource).AllowReordering().Columns(col => +{ +col.Field("OrderID").HeaderText("Order ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); +col.Field("CustomerID").HeaderText("Customer ID").Width("100").Add(); +col.Field("Freight").HeaderText("Freight").Width("120").Format("C").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); +col.Field("OrderDate").HeaderText("Order Date").Width("120").Format("yMd").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); +col.Field("ShipCountry").HeaderText("Ship Country").Width("130").Add(); +}).Render() + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/reordertargetcolumns/reorder.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/reordertargetcolumns/reorder.cs new file mode 100644 index 0000000000..a313f00f64 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/reordertargetcolumns/reorder.cs @@ -0,0 +1,6 @@ +public IActionResult Index() +{ + var Order = OrdersDetails.GetAllRecords(); + ViewBag.DataSource = Order; + return View(); +} \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/reordertargetcolumns/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/reordertargetcolumns/tagHelper new file mode 100644 index 0000000000..f5e6c86e6c --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/reordertargetcolumns/tagHelper @@ -0,0 +1,30 @@ +
+ + +
+ + + + + + + + + + + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/resize-external/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/resize-external/razor new file mode 100644 index 0000000000..6b60fb914e --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/resize-external/razor @@ -0,0 +1,27 @@ +
+ + + @Html.EJS().DropDownList("dropdown").Index(0).Width("180px").DataSource(new List { "OrderID", "CustomerID", "Freight", "OrderDate" }).Render() + + +
+ + @Html.EJS().TextBox("textbox").Placeholder("Enter new width").Width("220px").Render() + @Html.EJS().Button("buttons").Content("Resize").Render() +
+ @Html.EJS().Grid("Grid").DataSource((IEnumerable)ViewBag.DataSource).AllowResizing(true).Columns(col => + { + col.Field("OrderID").HeaderText("Order ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("CustomerID").HeaderText("Customer ID").Width("130").Add(); + col.Field("Freight").HeaderText("Freight").Width("120").Format("C").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("OrderDate").HeaderText("Order Date").Width("130").Format("yMd").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("ShipCountry").HeaderText("Ship Country").Width("120").Add(); + }).Render() + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/resize-external/resize.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/resize-external/resize.cs new file mode 100644 index 0000000000..a313f00f64 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/resize-external/resize.cs @@ -0,0 +1,6 @@ +public IActionResult Index() +{ + var Order = OrdersDetails.GetAllRecords(); + ViewBag.DataSource = Order; + return View(); +} \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/resize-external/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/resize-external/tagHelper new file mode 100644 index 0000000000..dddf1bd7a2 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/resize-external/tagHelper @@ -0,0 +1,30 @@ +
+ + + + +
+
+ + + + + +
+ + + + + + + + + + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/resize-max/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/resize-max/razor new file mode 100644 index 0000000000..31cc7ec82b --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/resize-max/razor @@ -0,0 +1,8 @@ +@Html.EJS().Grid("Grid").DataSource((IEnumerable)ViewBag.DataSource).AllowResizing(true).Columns(col => +{ + col.Field("OrderID").HeaderText("Order ID").MinWidth("100").Width("150").MaxWidth("250").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("CustomerID").HeaderText("Customer ID").MinWidth("150").Width("200").MaxWidth("300").Add(); + col.Field("Freight").HeaderText("Freight").Width("120").Format("C").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("OrderDate").HeaderText("Order Date").Width("100").Format("yMd").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("ShipCountry").HeaderText("Ship Country").MinWidth("120").Width("150").MaxWidth("260").Add(); +}).Render() \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/resize-max/resize.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/resize-max/resize.cs new file mode 100644 index 0000000000..a313f00f64 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/resize-max/resize.cs @@ -0,0 +1,6 @@ +public IActionResult Index() +{ + var Order = OrdersDetails.GetAllRecords(); + ViewBag.DataSource = Order; + return View(); +} \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/resize-max/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/resize-max/tagHelper new file mode 100644 index 0000000000..a9c9bb3624 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/resize-max/tagHelper @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/resize-mode/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/resize-mode/razor new file mode 100644 index 0000000000..b81671953d --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/resize-mode/razor @@ -0,0 +1,20 @@ +
+ + + @Html.EJS().DropDownList("dropdown").Index(0).Width("180px").DataSource(new List { "Normal", "Auto" }).Change("change").Render() + + +@Html.EJS().Grid("Grid").DataSource((IEnumerable)ViewBag.DataSource).AllowResizing(true).Columns(col => +{ + col.Field("OrderID").HeaderText("Order ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("CustomerID").HeaderText("Customer ID").AllowResizing(false).Width("130").Add(); + col.Field("Freight").HeaderText("Freight").Width("100").Format("C").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("OrderDate").HeaderText("Order Date").Width("130").Format("yMd").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("ShipAddress").HeaderText("Ship Address").Width("150").Add(); +}).Render() + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/resize-mode/resize.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/resize-mode/resize.cs new file mode 100644 index 0000000000..a313f00f64 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/resize-mode/resize.cs @@ -0,0 +1,6 @@ +public IActionResult Index() +{ + var Order = OrdersDetails.GetAllRecords(); + ViewBag.DataSource = Order; + return View(); +} \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/resize-mode/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/resize-mode/tagHelper new file mode 100644 index 0000000000..955e7ba9b3 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/resize-mode/tagHelper @@ -0,0 +1,22 @@ +
+ + + + +
+ + + + + + + + + + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/resize-prevent/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/resize-prevent/razor new file mode 100644 index 0000000000..33df1e3ab7 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/resize-prevent/razor @@ -0,0 +1,8 @@ +@Html.EJS().Grid("Grid").DataSource((IEnumerable)ViewBag.DataSource).AllowResizing(true).Columns(col => +{ + col.Field("OrderID").HeaderText("Order ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("CustomerID").HeaderText("Customer ID").AllowResizing(false).Width("130").Add(); + col.Field("Freight").HeaderText("Freight").Width("100").Format("C").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("OrderDate").HeaderText("Order Date").Width("130").Format("yMd").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("ShipAddress").HeaderText("Ship Address").Width("150").Add(); +}).Render() \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/valueaccessor/valueaccessor.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/resize-prevent/resize.cs similarity index 97% rename from ej2-asp-core-mvc/code-snippet/grid/columns/valueaccessor/valueaccessor.cs rename to ej2-asp-core-mvc/code-snippet/grid/columns/resize-prevent/resize.cs index 77d8fe70cf..f6f0126ac7 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/columns/valueaccessor/valueaccessor.cs +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/resize-prevent/resize.cs @@ -3,4 +3,4 @@ public IActionResult Index() var Order = OrderDetails.GetAllRecords(); ViewBag.DataSource = Order; return View(); -} +} \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/resize-prevent/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/resize-prevent/tagHelper new file mode 100644 index 0000000000..434066c9ac --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/resize-prevent/tagHelper @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/resize-stacked/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/resize-stacked/razor new file mode 100644 index 0000000000..d9b08d1df5 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/resize-stacked/razor @@ -0,0 +1,8 @@ +@Html.EJS().Grid("Grid").DataSource((IEnumerable)ViewBag.DataSource).AllowResizing(true).Columns(col => +{ + col.Field("OrderID").HeaderText("Order ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.HeaderText("Order Details").Columns(new List() { new Syncfusion.EJ2.Grids.GridColumn { Field = "OrderDate", Width = "135", HeaderText = "Order Date",TextAlign=Syncfusion.EJ2.Grids.TextAlign.Right,Format="yMd", MinWidth="10" }, + new Syncfusion.EJ2.Grids.GridColumn { Field = "Freight", Width = "130", TextAlign=Syncfusion.EJ2.Grids.TextAlign.Right, HeaderText = "Freight($)", Format="C2", MinWidth="10"} }).Add(); + col.HeaderText("Shipped Details").Columns(new List() { new Syncfusion.EJ2.Grids.GridColumn { Field = "ShipCity", Width = "140", HeaderText = "Ship City",AllowResizing=false, MinWidth="10" }, + new Syncfusion.EJ2.Grids.GridColumn { Field = "ShipCountry", Width = "145", HeaderText = "Ship Country", MinWidth="10" } }).Add(); +}).Render() \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/resize-stacked/resize.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/resize-stacked/resize.cs new file mode 100644 index 0000000000..a313f00f64 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/resize-stacked/resize.cs @@ -0,0 +1,6 @@ +public IActionResult Index() +{ + var Order = OrdersDetails.GetAllRecords(); + ViewBag.DataSource = Order; + return View(); +} \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/resize-stacked/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/resize-stacked/tagHelper new file mode 100644 index 0000000000..4efe654fb9 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/resize-stacked/tagHelper @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/resize/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/resize/razor index f57a3a8ff1..9bff8cfc30 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/columns/resize/razor +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/resize/razor @@ -1,12 +1,9 @@ -@Html.EJS().Grid("ColumnResize").DataSource((IEnumerable)ViewBag.dataSource).AllowResizing(true).Columns(col => +@Html.EJS().Grid("Grid").DataSource((IEnumerable)ViewBag.DataSource).AllowResizing(true).Columns(col => { - col.Field("OrderID").HeaderText("Order ID").Width("200").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); - col.Field("CustomerID").HeaderText("Customer Name").Width("150").Add(); - col.Field("OrderDate").HeaderText("Order Date").Width("200").Format("yMd").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); - col.Field("Freight").HeaderText("Freight").Width("150").Format("C2").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); - col.Field("ShipName").HeaderText("Ship Country").Width("300").Add(); - col.Field("ShippedDate").HeaderText("Shipped Date").Width("200").Format("yMd").AllowResizing(false).TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); - col.Field("ShipName").HeaderText("Ship Country").Width("200").Add(); - col.Field("ShipName").HeaderText("Ship Country").Width("200").Add(); - -}).AllowPaging().Render() \ No newline at end of file + col.Field("OrderID").HeaderText("Order ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("CustomerID").HeaderText("Customer ID").Width("130").Add(); + col.Field("Freight").HeaderText("Freight").Width("100").Format("C").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("OrderDate").HeaderText("Order Date").Width("130").Format("yMd").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("ShipCountry").HeaderText("Ship Country").Width("120").Add(); + col.Field("ShipAddress").HeaderText("Ship Address").Width("120").Add(); +}).Render() \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/resize/resize.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/resize/resize.cs index f6f0126ac7..a313f00f64 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/columns/resize/resize.cs +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/resize/resize.cs @@ -1,6 +1,6 @@ public IActionResult Index() { - var Order = OrderDetails.GetAllRecords(); + var Order = OrdersDetails.GetAllRecords(); ViewBag.DataSource = Order; return View(); } \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/resize/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/resize/tagHelper index 529ed21354..3502ff0dc4 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/columns/resize/tagHelper +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/resize/tagHelper @@ -1,12 +1,10 @@ - + - - - - - - - - + + + + + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/resizeevents/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/resizeevents/razor index 3f9c562c5e..eb2ffa4ca6 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/columns/resizeevents/razor +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/resizeevents/razor @@ -1,25 +1,38 @@ -@Html.EJS().Grid("ColumnResize").DataSource((IEnumerable)ViewBag.dataSource).AllowResizing(true).Columns(col => +
+

+
+@Html.EJS().Grid("Grid").DataSource((IEnumerable)ViewBag.DataSource).AllowResizing(true).Columns(col => { - col.Field("OrderID").HeaderText("Order ID").Width("200").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); - col.Field("CustomerID").HeaderText("Customer Name").Width("150").Add(); - col.Field("OrderDate").HeaderText("Order Date").Width("200").Format("yMd").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); - col.Field("Freight").HeaderText("Freight").Width("150").Format("C2").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); - col.Field("ShipName").HeaderText("Ship Country").Width("300").Add(); - col.Field("ShippedDate").HeaderText("Shipped Date").Width("200").Format("yMd").AllowResizing(false).TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); - col.Field("ShipName").HeaderText("Ship Country").Width("200").Add(); - -}).AllowPaging().ResizeStart("resizeStart").Resizing("resizing").ResizeStop("resizeStop").Render() - - \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/resizeevents/resize.cs b/ej2-asp-core-mvc/code-snippet/grid/columns/resizeevents/resize.cs new file mode 100644 index 0000000000..a313f00f64 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/resizeevents/resize.cs @@ -0,0 +1,6 @@ +public IActionResult Index() +{ + var Order = OrdersDetails.GetAllRecords(); + ViewBag.DataSource = Order; + return View(); +} \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/resizeevents/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/resizeevents/tagHelper index 3c0da5b6b6..d8a50a5619 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/columns/resizeevents/tagHelper +++ b/ej2-asp-core-mvc/code-snippet/grid/columns/resizeevents/tagHelper @@ -1,26 +1,41 @@ - +
+

+
+ + - - - - - - - - + + + + + - - \ No newline at end of file + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/valueaccessor/razor b/ej2-asp-core-mvc/code-snippet/grid/columns/valueaccessor/razor deleted file mode 100644 index 4187f2f6fb..0000000000 --- a/ej2-asp-core-mvc/code-snippet/grid/columns/valueaccessor/razor +++ /dev/null @@ -1,23 +0,0 @@ -@{ - var valueAccessor = "valueAccessorFn"; -} - -@Html.EJS().Grid("ValueAccessor").DataSource((IEnumerable)ViewBag.DataSource).Columns(col => -{ - col.Field("OrderID").HeaderText("Order ID").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Width("120").Add(); - col.Field("CustomerID").HeaderText("Customer Name").Width("150").Add(); - col.Field("ShipCity").HeaderText("Ship City").ValueAccessor(valueAccessor).Width("150").Add(); - col.Field("OrderDate").HeaderText("Order Date").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Width("130").Format("yMd").Add(); - col.Field("Freight").HeaderText("Freight").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Width("120").Format("C2").Add(); - -}).AllowPaging().Render() - - diff --git a/ej2-asp-core-mvc/code-snippet/grid/columns/valueaccessor/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/columns/valueaccessor/tagHelper deleted file mode 100644 index 1839560425..0000000000 --- a/ej2-asp-core-mvc/code-snippet/grid/columns/valueaccessor/tagHelper +++ /dev/null @@ -1,23 +0,0 @@ -@{ - var valueAccessor = "valueAccessorFn"; -} - - - - - - - - - - - - diff --git a/ej2-asp-core-mvc/code-snippet/grid/print/current-page/current-page.cs b/ej2-asp-core-mvc/code-snippet/grid/print/current-page/current-page.cs index 4019df2042..02cee14e8e 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/print/current-page/current-page.cs +++ b/ej2-asp-core-mvc/code-snippet/grid/print/current-page/current-page.cs @@ -1,5 +1,7 @@ public IActionResult Index() { - ViewBag.DataSource = OrderDetails.GetAllRecords(); + ViewBag.DataSource = OrdersDetails.GetAllRecords(); + ViewBag.dropdownData = new string[] { "AllPages", "CurrentPage" }; + return View(); } \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/print/current-page/razor b/ej2-asp-core-mvc/code-snippet/grid/print/current-page/razor index 608ab99ccb..b1029cf6a4 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/print/current-page/razor +++ b/ej2-asp-core-mvc/code-snippet/grid/print/current-page/razor @@ -1,9 +1,22 @@ -@Html.EJS().Grid("Print").DataSource((IEnumerable)ViewBag.DataSource).Columns(col => +
+ + + @Html.EJS().DropDownList("dropdown").Index(0).DataSource(@ViewBag.dropdownData).Change("change").Render() + +
+ +@Html.EJS().Grid("Grid").DataSource((IEnumerable)ViewBag.DataSource).Columns(col => { col.Field("OrderID").HeaderText("Order ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); - col.Field("CustomerID").HeaderText("Customer Name").Width("150").Add(); + col.Field("CustomerID").HeaderText("Customer ID").Width("150").Add(); col.Field("OrderDate").HeaderText("Order Date").Width("130").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Format("yMd").Add(); col.Field("Freight").HeaderText("Freight").Width("120").Format("C2").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); col.Field("ShipCountry").HeaderText("Ship Country").Width("150").Add(); -}).AllowPaging().Toolbar(new List() { "Print" }).PrintMode(Syncfusion.EJ2.Grids.PrintMode.CurrentPage).Render() \ No newline at end of file +}).AllowPaging().PageSettings(page => { page.PageSize(6); }).Toolbar(new List() { "Print" }).Render() + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/print/current-page/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/print/current-page/tagHelper index d3044d29ab..2199136bf4 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/print/current-page/tagHelper +++ b/ej2-asp-core-mvc/code-snippet/grid/print/current-page/tagHelper @@ -1,8 +1,23 @@ - +
+ + + + +
+ + + - - + + + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/print/external-btn/external-btn.cs b/ej2-asp-core-mvc/code-snippet/grid/print/external-btn/external-btn.cs index 4019df2042..47e5e3b61d 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/print/external-btn/external-btn.cs +++ b/ej2-asp-core-mvc/code-snippet/grid/print/external-btn/external-btn.cs @@ -1,5 +1,5 @@ public IActionResult Index() { - ViewBag.DataSource = OrderDetails.GetAllRecords(); + ViewBag.DataSource = OrdersDetails.GetAllRecords(); return View(); } \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/print/external-btn/razor b/ej2-asp-core-mvc/code-snippet/grid/print/external-btn/razor index b7230490fd..b638a92107 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/print/external-btn/razor +++ b/ej2-asp-core-mvc/code-snippet/grid/print/external-btn/razor @@ -1,5 +1,6 @@ -@Html.EJS().Button("printbtn").Content("Print").IsPrimary(true).Render() - +
+ @Html.EJS().Button("printbtn").Content("Print").IsPrimary(true).Render() +
@Html.EJS().Grid("Print").DataSource((IEnumerable)ViewBag.DataSource).Columns(col => { col.Field("OrderID").HeaderText("Order ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); diff --git a/ej2-asp-core-mvc/code-snippet/grid/print/external-btn/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/print/external-btn/tagHelper index 5eacdac9cf..56842ed7a9 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/print/external-btn/tagHelper +++ b/ej2-asp-core-mvc/code-snippet/grid/print/external-btn/tagHelper @@ -1,10 +1,13 @@ - +
+ +
- - + + + diff --git a/ej2-asp-core-mvc/code-snippet/grid/print/hierarchyprint/hierarchyprint.cs b/ej2-asp-core-mvc/code-snippet/grid/print/hierarchyprint/hierarchyprint.cs index f205693de8..f1bf5a0437 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/print/hierarchyprint/hierarchyprint.cs +++ b/ej2-asp-core-mvc/code-snippet/grid/print/hierarchyprint/hierarchyprint.cs @@ -3,5 +3,7 @@ public IActionResult Index() ViewBag.DataSource = OrdersDetails.GetAllRecords();; ViewBag.EmpDataSource = EmployeeView.GetAllRecords(); ViewBag.CustomerDataSource = Customer.GetAllRecords(); + ViewBag.dropdownData = new string[] { "Expanded", "All", "None" }; + return View(); } \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/print/hierarchyprint/razor b/ej2-asp-core-mvc/code-snippet/grid/print/hierarchyprint/razor index 1d5072cb01..802089591f 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/print/hierarchyprint/razor +++ b/ej2-asp-core-mvc/code-snippet/grid/print/hierarchyprint/razor @@ -5,6 +5,7 @@ { new Syncfusion.EJ2.Grids.GridColumn(){ Field="CustomerID", HeaderText="Customer ID", Width="90", TextAlign=Syncfusion.EJ2.Grids.TextAlign.Right }, new Syncfusion.EJ2.Grids.GridColumn(){ Field="ShipCountry", HeaderText="Ship Country", Width="90" }, + new Syncfusion.EJ2.Grids.GridColumn(){ Field="ShipAddress", HeaderText="ShipAddress", Width="90" }, } }; @@ -21,11 +22,23 @@ }; } -@Html.EJS().Grid("HierarchyPrint").DataSource((IEnumerable)ViewBag.EmpDataSource).HierarchyPrintMode(Syncfusion.EJ2.Grids.HierarchyGridPrintMode.All).Columns(col => -{ - col.Field("EmployeeID").HeaderText("Employee ID").Width("125").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); - col.Field("FirstName").HeaderText("Name").Width("125").Add(); - col.Field("Country").HeaderText("Country").Width("180").Add(); - col.Field("City").HeaderText("City").Width("135").Add(); +
+ + + @Html.EJS().DropDownList("dropdown").Index(0).DataSource(@ViewBag.dropdownData).Change("onModeChange").Render() + +
+ @Html.EJS().Grid("HierarchyPrint").DataSource((IEnumerable)ViewBag.EmpDataSource).Columns(col => + { + col.Field("EmployeeID").HeaderText("Employee ID").Width("125").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("FirstName").HeaderText("Name").Width("125").Add(); + col.Field("Country").HeaderText("Country").Width("180").Add(); + col.Field("City").HeaderText("City").Width("135").Add(); -}).AllowSorting().Toolbar(new List() { "Print"}).ChildGrid(ChildGrid).Render() + }).Toolbar(new List() { "Print" }).ChildGrid(ChildGrid).Render() + diff --git a/ej2-asp-core-mvc/code-snippet/grid/print/hierarchyprint/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/print/hierarchyprint/tagHelper index 50a70db576..003d4c9362 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/print/hierarchyprint/tagHelper +++ b/ej2-asp-core-mvc/code-snippet/grid/print/hierarchyprint/tagHelper @@ -1,35 +1,51 @@ - @{ - var SecondChildGrid = new Syncfusion.EJ2.Grids.Grid() - { - DataSource = (IEnumerable)ViewBag.CustomerDataSource, - QueryString = "CustomerID", - Columns = new List { + +@{ + var SecondChildGrid = new Syncfusion.EJ2.Grids.Grid() + { + DataSource = (IEnumerable)ViewBag.CustomerDataSource, + QueryString = "CustomerID", + Columns = new List { new Syncfusion.EJ2.Grids.GridColumn(){ Field="CustomerID", HeaderText="Customer ID", Width="90", TextAlign=Syncfusion.EJ2.Grids.TextAlign.Right }, new Syncfusion.EJ2.Grids.GridColumn(){ Field="ShipCountry", HeaderText="Country", Width="90" }, - } - }; - } + new Syncfusion.EJ2.Grids.GridColumn(){ Field="ShipAddress", HeaderText="Ship Address", Width="90" }, + + } + }; +} - @{ - var ChildGrid = new Syncfusion.EJ2.Grids.Grid() { - DataSource = (IEnumerable)ViewBag.DataSource, - QueryString = "EmployeeID", - Columns = new List { +@{ + var ChildGrid = new Syncfusion.EJ2.Grids.Grid() + { + DataSource = (IEnumerable)ViewBag.DataSource, + QueryString = "EmployeeID", + Columns = new List { new Syncfusion.EJ2.Grids.GridColumn(){ Field="OrderID", HeaderText="Order ID", Width="120" }, new Syncfusion.EJ2.Grids.GridColumn(){ Field="Freight", HeaderText="Freight", Width="120", Format="C2", TextAlign=Syncfusion.EJ2.Grids.TextAlign.Right }, new Syncfusion.EJ2.Grids.GridColumn(){ Field="ShipName", HeaderText="Ship Name", Width="150" }, new Syncfusion.EJ2.Grids.GridColumn(){ Field="ShipCity", HeaderText="Ship City", Width="120" }, - }, - ChildGrid = SecondChildGrid - }; - } + }, + ChildGrid = SecondChildGrid + }; +} - +
+ + + + +
+ - + + diff --git a/ej2-asp-core-mvc/code-snippet/grid/print/masterdetailgrid/masterdetailgrid.cs b/ej2-asp-core-mvc/code-snippet/grid/print/masterdetailgrid/masterdetailgrid.cs index f650c2d757..35e0c7fa1c 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/print/masterdetailgrid/masterdetailgrid.cs +++ b/ej2-asp-core-mvc/code-snippet/grid/print/masterdetailgrid/masterdetailgrid.cs @@ -1,5 +1,6 @@ public IActionResult Index() { - ViewBag.dataSource = OrderDetails.GetAllRecords(); + ViewBag.DataSource = OrdersDetails.GetAllRecords(); + ViewBag.EmployeeData =Employees.GetAllRecords(); return View(); } \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/print/masterdetailgrid/razor b/ej2-asp-core-mvc/code-snippet/grid/print/masterdetailgrid/razor index 50964a633d..3846fca91b 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/print/masterdetailgrid/razor +++ b/ej2-asp-core-mvc/code-snippet/grid/print/masterdetailgrid/razor @@ -1,36 +1,42 @@
Master Grid - @Html.EJS().Grid("masterGrid").DataSource((IEnumerable)ViewBag.dataSource).Width("auto").SelectedRowIndex(0).Columns(col => - { - col.Field("EmployeeID").HeaderText("EmployeeID").IsPrimaryKey(true).Add(); - col.Field("OrderID").HeaderText("OrderID").Add(); - col.Field("CustomerID").HeaderText("FirstName").Add(); - }).RowSelected("selected").BeforePrint("beforePrint").Toolbar(new List() { "Print" }).Render() + @Html.EJS().Grid("masterGrid").DataSource((IEnumerable)ViewBag.EmployeeData).SelectedRowIndex(1).Columns(col => +{ + col.Field("ContactName").HeaderText("Customer Name").Width(150).Add(); + col.Field("CompanyName").HeaderText("CompanyName").Width(150).Add(); + col.Field("Address").HeaderText("Address").Width(150).Add(); + col.Field("Country").HeaderText("Country").Width(130).Add(); + +}).RowSelected("rowSelected").BeforePrint("beforePrint").Toolbar(new List() { "Print" }).Render() -

Showing orders of Customer:

+

Showing orders of Customer:

- @Html.EJS().Grid("detailGrid").DataSource((IEnumerable)ViewBag.dataSource1).Columns(col => - { - col.Field("EmployeeID").HeaderText("EmployeeID").IsPrimaryKey(true).Add(); - col.Field("ShipCountry").HeaderText("ShipCountry").Add(); - col.Field("ShipName").HeaderText("ShipName").Add(); - }).Render() +@Html.EJS().Grid("childGrid").Columns(col => +{ + col.Field("OrderID").HeaderText("Order ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("Freight").HeaderText("Freight").Width("120").Format("C2").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("ShipName").HeaderText("Ship Name").Width("120").Add(); + col.Field("ShipAddress").HeaderText("Ship Address").Width("150").Add(); + col.Field("ShipCountry").HeaderText("Ship Country").Width("150").Add(); + + +}).Render() \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/print/masterdetailgrid/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/print/masterdetailgrid/tagHelper index 6b00303b69..4a36a45612 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/print/masterdetailgrid/tagHelper +++ b/ej2-asp-core-mvc/code-snippet/grid/print/masterdetailgrid/tagHelper @@ -1,40 +1,43 @@ @using System.Text.Json;
- + - - - + + + +
-

Showing orders of Customer:

-
- - - - - - - -
+

Showing orders of Customer:

+ + + + + + + + + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/print/print-custom/print.cs b/ej2-asp-core-mvc/code-snippet/grid/print/print-custom/print.cs new file mode 100644 index 0000000000..47e5e3b61d --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/print/print-custom/print.cs @@ -0,0 +1,5 @@ +public IActionResult Index() +{ + ViewBag.DataSource = OrdersDetails.GetAllRecords(); + return View(); +} \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/print/print-custom/razor b/ej2-asp-core-mvc/code-snippet/grid/print/print-custom/razor new file mode 100644 index 0000000000..958b1ad0b7 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/print/print-custom/razor @@ -0,0 +1,42 @@ +
+ @Html.EJS().Button("print").CssClass("e-danger").Content("Print").Render() +
+@Html.EJS().Grid("HierarchyPrint").DataSource((IEnumerable)ViewBag.DataSource).Columns(col => +{ + col.Field("OrderDate").HeaderText("Order Date").Width("130").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Format("yMd").Add(); + col.Field("Freight").HeaderText("Freight").Width("120").Format("C2").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + +}).AllowPaging().PageSettings(page => { page.PageSize(10); }).PrintMode(Syncfusion.EJ2.Grids.PrintMode.CurrentPage).ActionComplete("actionComplete").DataBound("dataBound").BeforePrint("beforePrint").Render() + +@Html.EJS().Chart("chart").Series(series => +{ + series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Line).Width(1).XName("OrderDate") + .YName("Freight").ColumnWidth(0.4).Marker(mr => mr.Visible(true)).Add(); + +}).PrimaryXAxis(px =>px.ValueType(Syncfusion.EJ2.Charts.ValueType.DateTime) +.LabelFormat("MMMd")).PrimaryYAxis(py =>py.LabelFormat("{value}")).Title("Order Data").Render() + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/print/print-custom/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/print/print-custom/tagHelper new file mode 100644 index 0000000000..b91d952122 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/print/print-custom/tagHelper @@ -0,0 +1,55 @@ +
+ +
+ + + + + + + + + + +

Chart

+
+ + + + + + + + + +
+ + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/print/print-select/print.cs b/ej2-asp-core-mvc/code-snippet/grid/print/print-select/print.cs new file mode 100644 index 0000000000..47e5e3b61d --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/print/print-select/print.cs @@ -0,0 +1,5 @@ +public IActionResult Index() +{ + ViewBag.DataSource = OrdersDetails.GetAllRecords(); + return View(); +} \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/print/print-select/razor b/ej2-asp-core-mvc/code-snippet/grid/print/print-select/razor new file mode 100644 index 0000000000..f7a7496d08 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/print/print-select/razor @@ -0,0 +1,22 @@ +@Html.EJS().Grid("Grid").DataSource((IEnumerable)ViewBag.DataSource).BeforePrint("beforePrint").Columns(col => +{ + col.Field("OrderID").HeaderText("Order ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("CustomerID").HeaderText("Customer ID").Width("150").Add(); + col.Field("ShipCity").HeaderText("Ship City").Width("150").Add(); + col.Field("ShipName").HeaderText("Ship Name").Width("150").Add(); + +}).AllowPaging().SelectionSettings(select => select.Type(Syncfusion.EJ2.Grids.SelectionType.Multiple)).PageSettings(page => page.PageSize(6)).Toolbar(new List() { "Print" }).Render() + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/print/print-select/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/print/print-select/tagHelper new file mode 100644 index 0000000000..12f97906c9 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/print/print-select/tagHelper @@ -0,0 +1,25 @@ + + + + + + + + + + + diff --git a/ej2-asp-core-mvc/code-snippet/grid/print/print-style/print.cs b/ej2-asp-core-mvc/code-snippet/grid/print/print-style/print.cs new file mode 100644 index 0000000000..47e5e3b61d --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/print/print-style/print.cs @@ -0,0 +1,5 @@ +public IActionResult Index() +{ + ViewBag.DataSource = OrdersDetails.GetAllRecords(); + return View(); +} \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/print/print-style/razor b/ej2-asp-core-mvc/code-snippet/grid/print/print-style/razor new file mode 100644 index 0000000000..196351c334 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/print/print-style/razor @@ -0,0 +1,37 @@ +@Html.EJS().Grid("Grid").DataSource((IEnumerable)ViewBag.DataSource).BeforePrint("beforePrint").Columns(col => +{ + col.Field("OrderID").HeaderText("Order ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("CustomerID").HeaderText("Customer ID").Width("150").Add(); + col.Field("ShipCity").HeaderText("Ship City").Width("150").Add(); + col.Field("ShipName").HeaderText("Ship Name").Width("150").Add(); + +}).Toolbar(new List() { "Print" }).Render() + + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/print/print-style/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/print/print-style/tagHelper new file mode 100644 index 0000000000..06179efa8a --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/print/print-style/tagHelper @@ -0,0 +1,36 @@ + + + + + + + + + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/print/print/print.cs b/ej2-asp-core-mvc/code-snippet/grid/print/print/print.cs index 4019df2042..47e5e3b61d 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/print/print/print.cs +++ b/ej2-asp-core-mvc/code-snippet/grid/print/print/print.cs @@ -1,5 +1,5 @@ public IActionResult Index() { - ViewBag.DataSource = OrderDetails.GetAllRecords(); + ViewBag.DataSource = OrdersDetails.GetAllRecords(); return View(); } \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/print/print/razor b/ej2-asp-core-mvc/code-snippet/grid/print/print/razor index 4cb27541ab..1e350d417c 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/print/print/razor +++ b/ej2-asp-core-mvc/code-snippet/grid/print/print/razor @@ -3,7 +3,7 @@ col.Field("OrderID").HeaderText("Order ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); col.Field("CustomerID").HeaderText("Customer Name").Width("150").Add(); col.Field("OrderDate").HeaderText("Order Date").Width("130").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Format("yMd").Add(); - col.Field("Freight").HeaderText("Freight").Width("120").Format("C2").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("Freight").HeaderText("Freight").Width("130").Format("C2").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); col.Field("ShipCountry").HeaderText("Ship Country").Width("150").Add(); }).AllowPaging().Toolbar(new List() { "Print" }).Render() \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/print/print/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/print/print/tagHelper index 7432d706db..185529820c 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/print/print/tagHelper +++ b/ej2-asp-core-mvc/code-snippet/grid/print/print/tagHelper @@ -1,8 +1,9 @@ - + - - + + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/print/show-hide-columns/razor b/ej2-asp-core-mvc/code-snippet/grid/print/show-hide-columns/razor index b381685cd3..2e5368d1f9 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/print/show-hide-columns/razor +++ b/ej2-asp-core-mvc/code-snippet/grid/print/show-hide-columns/razor @@ -1,33 +1,31 @@ -@Html.EJS().Grid("Print").DataSource((IEnumerable)ViewBag.DataSource).ToolbarClick("toolbarClick").PrintComplete("printComplete").Columns(col => +@Html.EJS().Grid("Grid").DataSource((IEnumerable)ViewBag.DataSource).ToolbarClick("toolbarClick").PrintComplete("printComplete").Columns(col => { col.Field("OrderID").HeaderText("Order ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); - col.Field("CustomerID").HeaderText("Customer Name").Visible(false).Width("150").Add(); - col.Field("OrderDate").HeaderText("Order Date").Width("130").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Format("yMd").Add(); - col.Field("Freight").HeaderText("Freight").Width("120").Format("C2").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + col.Field("CustomerID").HeaderText("Customer ID").Visible(false).Width("150").Add(); col.Field("ShipCity").HeaderText("Ship City").Width("150").Add(); + col.Field("ShipName").HeaderText("Ship Name").Width("150").Add(); -}).AllowPaging().Toolbar(new List() { "Print" }).Render() +}).Toolbar(new List() { "Print" }).Render() \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/print/show-hide-columns/show-hide.cs b/ej2-asp-core-mvc/code-snippet/grid/print/show-hide-columns/show-hide.cs index 4019df2042..47e5e3b61d 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/print/show-hide-columns/show-hide.cs +++ b/ej2-asp-core-mvc/code-snippet/grid/print/show-hide-columns/show-hide.cs @@ -1,5 +1,5 @@ public IActionResult Index() { - ViewBag.DataSource = OrderDetails.GetAllRecords(); + ViewBag.DataSource = OrdersDetails.GetAllRecords(); return View(); } \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/print/show-hide-columns/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/print/show-hide-columns/tagHelper index f1392949a0..088972d0fe 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/print/show-hide-columns/tagHelper +++ b/ej2-asp-core-mvc/code-snippet/grid/print/show-hide-columns/tagHelper @@ -1,4 +1,4 @@ - + @@ -6,27 +6,25 @@ - \ No newline at end of file diff --git a/ej2-asp-core-mvc/document-editor/collaborative-editing/overview.md b/ej2-asp-core-mvc/document-editor/collaborative-editing/overview.md new file mode 100644 index 0000000000..71714f8f8e --- /dev/null +++ b/ej2-asp-core-mvc/document-editor/collaborative-editing/overview.md @@ -0,0 +1,44 @@ +--- +layout: post +title: Collaborative Editing in ##Platform_Name## Document Editor Control | Syncfusion +component: DocumentEditor +description: Learn about collaborative editing in Syncfusion ##Platform_Name## Document editor control of Syncfusion Essential JS 2 and more. +platform: ej2-asp-core-mvc +publishingplatform: ##Platform_Name## +documentation: ug +domainurl: ##DomainURL## +--- + +# Collaborative Editing + +Allows multiple users to work on the same document simultaneously. This can be done in real-time, so that collaborators can see the changes as they are made. Collaborative editing can be a great way to improve efficiency, as it allows team members to work together on a document without having to wait for others to finish their changes. + +## Prerequisites + +- *Real-time Transport Protocol*: This protocol facilitates instant communication between clients and the server, ensuring immediate updates during collaborative editing. +- *Distributed Cache or Database*: Used to temporarily store the queue of editing operations. + +### Real time transport protocol + +- *Managing Connections*: Keeps active connections open for real-time collaboration, allowing seamless communication between users and the server. +- *Broadcasting Changes*: Ensures that any edits made by one user are instantly sent to all collaborators, keeping everyone on the same page with the latest document version. + +### Distributed cache or database + +To support collaborative editing, it's crucial to have a backing system that temporarily stores the editing operations of all active users. There are two primary options: + +- *Distributed Cache*: Handles a higher number of `HTTP` requests per second compared to a database approach. For instance, a server with 2 vCPUs and 8GB RAM can handle up to 125 requests per second using a distributed cache. +- *Database*: With the same server configuration, it can handle up to 50 requests per second. + +Using the distributed cache or database all the editing operations are queued in order and conflict resolution is performed using `Operational Transformation` Algorithm. + +> *Recommendation* - If you expect average `http` requests per second of your live application as 50 or below, then the database can provide reliable a backing system for operation queue. If you expect average requests per second of your live application as above 50, then the distributed cache is highly recommended backing system. + +> Tips to calculate the average requests per second of your application: +Assume the editor in your live application is actively used by 1000 users and each user's edit can trigger 2 to 5 requests per second. The total requests per second of your applications will be around 2000 to 5000. In this case, you can finalize a configuration to support around 5000 average requests per second. + +> Note: The above metrics are based solely on the collaborative editing module. Actual throughput may decrease depending on other server-side interactions, such as document importing, pasting formatted content, editing restrictions, and spell checking. Therefore, it is advisable to monitor your app's traffic and choose a configuration that best suits your needs. +#### See Also + +- [Collaborative editing using Redis cache in ASP.NET Core](../../document-editor/collaborative-editing/using-distributed-cache-asp-net-core) +- [Collaborative editing using Microsoft SQL server in ASP.NET Core](../../document-editor/collaborative-editing/using-database-in-asp-net-core) \ No newline at end of file diff --git a/ej2-asp-core-mvc/document-editor/collaborative-editing.md b/ej2-asp-core-mvc/document-editor/collaborative-editing/using-dot-net.md similarity index 97% rename from ej2-asp-core-mvc/document-editor/collaborative-editing.md rename to ej2-asp-core-mvc/document-editor/collaborative-editing/using-dot-net.md index 3b37c5d1f3..b3561fb441 100644 --- a/ej2-asp-core-mvc/document-editor/collaborative-editing.md +++ b/ej2-asp-core-mvc/document-editor/collaborative-editing/using-dot-net.md @@ -1,384 +1,385 @@ ---- -title: Collaborative Editing in ##Platform_Name## Document Editor Control | Syncfusion -component: DocumentEditor -description: Learn how to enable and perform collaborative editing in Syncfusion ##Platform_Name## Document editor. -publishingplatform: ##Platform_Name## ---- - -# Collaborative Editing - -Allows multiple users to work on the same document simultaneously. This can be done in real-time, so that collaborators can see the changes as they are made. Collaborative editing can be a great way to improve efficiency, as it allows team members to work together on a document without having to wait for others to finish their changes. - -## Prerequisites - -Following things are needed to enable collaborative editing in Document Editor - -- SignalR -- Microsoft SQL Server - -## How to enable collaborative editing in client side - -### Step 1: Enable collaborative editing in Document Editor - -To enable collaborative editing, inject `CollaborativeEditingHandler` and set the property `enableCollaborativeEditing` to true in the Document Editor, like in the code snippet below. - -{% if page.publishingplatform == "aspnet-core" %} - -{% tabs %} -{% highlight cshtml tabtitle="CSHTML" %} -{% include code-snippet/document-editor/collaborative-editing/tagHelper %} -{% endhighlight %} -{% highlight c# tabtitle="Document-editor.cs" %} -{% include code-snippet/document-editor/collaborative-editing/document-editor.cs %} -{% endhighlight %} -{% endtabs %} - -{% elsif page.publishingplatform == "aspnet-mvc" %} - -{% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/document-editor/collaborative-editing/razor %} -{% endhighlight %} -{% highlight c# tabtitle="Document-editor.cs" %} -{% include code-snippet/document-editor/collaborative-editing/document-editor.cs %} -{% endhighlight %} -{% endtabs %} -{% endif %} - -## Step 2: Configure SignalR to send and receive changes - -To broadcast the changes made and receive changes from remote users, configure SignalR like below. - -{% if page.publishingplatform == "aspnet-core" %} - -{% tabs %} -{% highlight cshtml tabtitle="CSHTML" %} -{% include code-snippet/document-editor/collaborative-editing/script-1 %} -{% endhighlight %} -{% endtabs %} - -{% elsif page.publishingplatform == "aspnet-mvc" %} - -{% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/document-editor/collaborative-editing/script-1 %} -{% endhighlight %} -{% endtabs %} -{% endif %} - -### Step 3: Join SignalR room while opening the document - -When opening a document, we need to generate a unique ID for each document. These unique IDs are then used to create rooms using SignalR, which facilitates sending and receiving data from the server. - -{% if page.publishingplatform == "aspnet-core" %} - -{% tabs %} -{% highlight cshtml tabtitle="CSHTML" %} -{% include code-snippet/document-editor/collaborative-editing/script-2 %} -{% endhighlight %} -{% endtabs %} - -{% elsif page.publishingplatform == "aspnet-mvc" %} - -{% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/document-editor/collaborative-editing/script-2 %} -{% endhighlight %} -{% endtabs %} -{% endif %} - -### Step 5: Broadcast current editing changes to remote users - -Changes made on the client-side need to be sent to the server-side to broadcast them to other connected users. To send the changes made to the server, use the method shown below from the document editor using the `contentChange` event. - -{% if page.publishingplatform == "aspnet-core" %} - -{% tabs %} -{% highlight cshtml tabtitle="CSHTML" %} -{% include code-snippet/document-editor/collaborative-editing/script-3 %} -{% endhighlight %} -{% endtabs %} - -{% elsif page.publishingplatform == "aspnet-mvc" %} - -{% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/document-editor/collaborative-editing/script-3 %} -{% endhighlight %} -{% endtabs %} -{% endif %} - -## How to enable collaborative editing in ASP.NET Core - -### Step 1: Configure SignalR in ASP.NET Core - -We are using Microsoft SignalR to broadcast the changes. Please add the following configuration to your application's Program.cs file. - -```csharp - using Microsoft.Azure.SignalR; - ..... - builder.Services.AddSignalR(); - ..... - ..... - ..... - app.MapHub("/documenteditorhub"); - ..... - ..... -``` - -### Step 2: Configure SignalR hub to create room for collaborative editing session - -To manage groups for each document, create a folder named "Hub" and add a file named "DocumentEditorHub.cs" inside it. Add the following code to the file to manage SignalR groups using room names. - -Join the group by using unique id of the document by using `JoinGroup` method. - -```csharp -static Dictionary userManager = new Dictionary(); - internal static Dictionary> groupManager = new Dictionary>(); - - // Join to the specified room name - public async Task JoinGroup(ActionInfo info) - { - if (!userManager.ContainsKey(Context.ConnectionId)) - { - userManager.Add(Context.ConnectionId, info); - } - info.ConnectionId = Context.ConnectionId; - //Add the current connected use to the specified group - await Groups.AddToGroupAsync(Context.ConnectionId, info.RoomName); - if (groupManager.ContainsKey(info.RoomName)) - { - await Clients.Caller.SendAsync("dataReceived", "addUser", groupManager[info.RoomName]); - } - lock (groupManager) - { - if (groupManager.ContainsKey(info.RoomName)) - { - groupManager[info.RoomName].Add(info); - } - else - { - List actions = new List - { - info - }; - groupManager.Add(info.RoomName, actions); - } - } - // Notify other users in the group about new user joined the collaborative editing session. - Clients.GroupExcept(info.RoomName, Context.ConnectionId).SendAsync("dataReceived", "addUser", info); - } - -``` - -Handle user disconnection using SignalR. - -```csharp -//Handle disconnection from group. - public override Task OnDisconnectedAsync(Exception? e) - { - string roomName = userManager[Context.ConnectionId].RoomName; - if (groupManager.ContainsKey(roomName)) - { - groupManager[roomName].Remove(userManager[Context.ConnectionId]); - - if (groupManager[roomName].Count == 0) - { - groupManager.Remove(roomName); -//If all user disconnected from current room. Auto save the change to source document. -CollaborativeEditingController.UpdateOperationsToSourceDocument(roomName, “<>”, false); - } - } - - if (userManager.ContainsKey(Context.ConnectionId)) - { - //Notify other user in the group about user exit the collaborative editing session - Clients.OthersInGroup(roomName).SendAsync("dataReceived", "removeUser", Context.ConnectionId); - Groups.RemoveFromGroupAsync(Context.ConnectionId, roomName); - userManager.Remove(Context.ConnectionId); - } - return base.OnDisconnectedAsync(e); - } - -``` - -### Step 3: Configure Microsoft SQL database connection string in application level - -Configure the SQL database that stores temporary data for the collaborative editing session. Provide the SQL database connection string in `appsettings.json` file. - -```json -..... -"ConnectionStrings": { - "DocumentEditorDatabase": "" -} -..... - -``` - -### Step 4: Configure Web API actions for collaborative editing - -#### Import File - -1. When opening a document, create a database table to store temporary data for the collaborative editing session. -2. If the table already exists, retrieve the records from the table and apply them to the WordDocument instance using the `UpdateActions` method before converting it to the SFDT format. - -```csharp -public string ImportFile([FromBody] FileInfo param) - { - ..... - ..... - DocumentContent content = new DocumentContent(); - - ..... - //Get source document from database/file system/blob storage - WordDocument document = GetDocumentFromDatabase(param.fileName, param.documentOwner); - ..... - //Get temporary records from database - List actions = CreatedTable(param.fileName); - if(actions!=null) - { - //Apply temporary data to the document. - document.UpdateActions(actions); - } - string json = Newtonsoft.Json.JsonConvert.SerializeObject(document); - content.version = 0; - content.sfdt = json; - return Newtonsoft.Json.JsonConvert.SerializeObject(content); - } - -``` - -#### Update editing records to database. - -Each edit operation made by the user is sent to the server and is pushed to the database. Each operation receives a version number after being inserted into the database. -After inserting the records to the server, the position of the current editing operation must be transformed against any previous editing operations not yet synced with the client using the TransformOperation method. -After performing the transformation, the current operation is broadcast to all connected users within the group. - -```csharp -public async Task UpdateAction([FromBody] ActionInfo param) -{ - try - { - ActionInfo modifiedAction = AddOperationsToTable(param); - //After transformation broadcast changes to all users in the gropu - await _hubContext.Clients.Group(param.RoomName).SendAsync("dataReceived", "action", modifiedAction); - return modifiedAction; - } - catch - { - return null; - } -} - -private ActionInfo AddOperationsToTable(ActionInfo action) - { - int clientVersion = action.Version; - string tableName = action.RoomName; - ………… - ………… - ………… - ………… - List actions = GetOperationsQueue(table); - foreach (ActionInfo info in actions) - { - if (!info.IsTransformed) - { - CollaborativeEditingHandler.TransformOperation(info, actions); - } - } - action = actions[actions.Count - 1]; - action.Version = updateVersion; - //Return the transformed operation to broadcast it to other clients. - return action; - } - -``` - -#### Add Web API to get previous operation as a backup to get lost operations - -On the client side, messages broadcast using SignalR may be received in a different order, or some operations may be missed due to network issues. In these cases, we need a backup method to retrieve missing records from the database. -Using the following method, we can retrieve all operations after the last successful client-synced version and return all missing operations to the requesting client. - -```csharp -public async Task UpdateAction([FromBody] ActionInfo param) -{ - try - { - ActionInfo modifiedAction = AddOperationsToTable(param); - //After transformation broadcast changes to all users in the group - await _hubContext.Clients.Group(param.RoomName).SendAsync("dataReceived", "action", modifiedAction); - return modifiedAction; - } - catch - { - return null; - } -} - -private ActionInfo AddOperationsToTable(ActionInfo action) - { - int clientVersion = action.Version; - string tableName = action.RoomName; - ………… - ………… - ………… - ………… - List actions = GetOperationsQueue(table); - foreach (ActionInfo info in actions) - { - if (!info.IsTransformed) - { - CollaborativeEditingHandler.TransformOperation(info, actions); - } - } - action = actions[actions.Count - 1]; - action.Version = updateVersion; - //Return the transformed operation to broadcast it to other clients. - return action; - } - -``` -## How to perform Scaling in Collaborative Editing. - -As the number of user increases, maintaining responsiveness and performance becomes challenging. Scaling tackles this by distributing the workload across resources. You can scale the collaborative editing application using either ```Azure SignalR service or Redis backplane service``` - -### 1. Scaling with Azure SignalR - -Azure SignalR Service is a scalable, managed service for real-time communication in web applications. It enables real-time messaging between web clients (browsers) and your server-side application(across multiple servers). - -Below is a code snippet to configure Azure SignalR in an ASP.NET Core application using the ```AddAzureSignalR``` method - -```csharp -builder.Services.AddSignalR() .AddAzureSignalR("", options => { -// Specify the channel name -options.Channels.Add("document-editor"); - }); -``` - -### 2. Scaling with Redis backplane - -Using a Redis backplane, you achieve horizontal scaling of your SignalR application. The SignalR leverages Redis to efficiently broadcast messages across multiple servers. This allows your application to handle large user bases with minimal latency. - -In the SignalR app, install the following NuGet package: -* ` Microsoft.AspNetCore.SignalR.StackExchangeRedis` - -Below is a code snippet to configure Redis backplane in an ASP.NET Core application using the ```AddStackExchangeRedis ``` method - -```csharp -builder.Services.AddSignalR().AddStackExchangeRedis(""); -``` -Configure options as needed: - -The following example shows how to add a channel prefix in the ConfigurationOptions object. - -```csharp -builder.Services.AddDistributedMemoryCache().AddSignalR().AddStackExchangeRedis(connectionString, options => - { - options.Configuration.ChannelPrefix = "document-editor"; - }); -``` - - -Full version of the code discussed about can be found in below GitHub location. - -GitHub Example: [`Collaborative editing examples`](https://github.com/SyncfusionExamples/EJ2-Document-Editor-Collabrative-Editing) +--- +title: Collaborative Editing in ##Platform_Name## Document Editor Control | Syncfusion +component: DocumentEditor +description: Learn how to enable and perform collaborative editing in Syncfusion ##Platform_Name## Document editor. +platform: ej2-asp-core-mvc +publishingplatform: ##Platform_Name## +--- + +# Collaborative Editing + +Allows multiple users to work on the same document simultaneously. This can be done in real-time, so that collaborators can see the changes as they are made. Collaborative editing can be a great way to improve efficiency, as it allows team members to work together on a document without having to wait for others to finish their changes. + +## Prerequisites + +Following things are needed to enable collaborative editing in Document Editor + +- SignalR +- Microsoft SQL Server + +## How to enable collaborative editing in client side + +### Step 1: Enable collaborative editing in Document Editor + +To enable collaborative editing, inject `CollaborativeEditingHandler` and set the property `enableCollaborativeEditing` to true in the Document Editor, like in the code snippet below. + +{% if page.publishingplatform == "aspnet-core" %} + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/document-editor/collaborative-editing/tagHelper %} +{% endhighlight %} +{% highlight c# tabtitle="Document-editor.cs" %} +{% include code-snippet/document-editor/collaborative-editing/document-editor.cs %} +{% endhighlight %} +{% endtabs %} + +{% elsif page.publishingplatform == "aspnet-mvc" %} + +{% tabs %} +{% highlight razor tabtitle="CSHTML" %} +{% include code-snippet/document-editor/collaborative-editing/razor %} +{% endhighlight %} +{% highlight c# tabtitle="Document-editor.cs" %} +{% include code-snippet/document-editor/collaborative-editing/document-editor.cs %} +{% endhighlight %} +{% endtabs %} +{% endif %} + +## Step 2: Configure SignalR to send and receive changes + +To broadcast the changes made and receive changes from remote users, configure SignalR like below. + +{% if page.publishingplatform == "aspnet-core" %} + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/document-editor/collaborative-editing/script-1 %} +{% endhighlight %} +{% endtabs %} + +{% elsif page.publishingplatform == "aspnet-mvc" %} + +{% tabs %} +{% highlight razor tabtitle="CSHTML" %} +{% include code-snippet/document-editor/collaborative-editing/script-1 %} +{% endhighlight %} +{% endtabs %} +{% endif %} + +### Step 3: Join SignalR room while opening the document + +When opening a document, we need to generate a unique ID for each document. These unique IDs are then used to create rooms using SignalR, which facilitates sending and receiving data from the server. + +{% if page.publishingplatform == "aspnet-core" %} + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/document-editor/collaborative-editing/script-2 %} +{% endhighlight %} +{% endtabs %} + +{% elsif page.publishingplatform == "aspnet-mvc" %} + +{% tabs %} +{% highlight razor tabtitle="CSHTML" %} +{% include code-snippet/document-editor/collaborative-editing/script-2 %} +{% endhighlight %} +{% endtabs %} +{% endif %} + +### Step 5: Broadcast current editing changes to remote users + +Changes made on the client-side need to be sent to the server-side to broadcast them to other connected users. To send the changes made to the server, use the method shown below from the document editor using the `contentChange` event. + +{% if page.publishingplatform == "aspnet-core" %} + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/document-editor/collaborative-editing/script-3 %} +{% endhighlight %} +{% endtabs %} + +{% elsif page.publishingplatform == "aspnet-mvc" %} + +{% tabs %} +{% highlight razor tabtitle="CSHTML" %} +{% include code-snippet/document-editor/collaborative-editing/script-3 %} +{% endhighlight %} +{% endtabs %} +{% endif %} + +## How to enable collaborative editing in ASP.NET Core + +### Step 1: Configure SignalR in ASP.NET Core + +We are using Microsoft SignalR to broadcast the changes. Please add the following configuration to your application's Program.cs file. + +```csharp + using Microsoft.Azure.SignalR; + ..... + builder.Services.AddSignalR(); + ..... + ..... + ..... + app.MapHub("/documenteditorhub"); + ..... + ..... +``` + +### Step 2: Configure SignalR hub to create room for collaborative editing session + +To manage groups for each document, create a folder named "Hub" and add a file named "DocumentEditorHub.cs" inside it. Add the following code to the file to manage SignalR groups using room names. + +Join the group by using unique id of the document by using `JoinGroup` method. + +```csharp +static Dictionary userManager = new Dictionary(); + internal static Dictionary> groupManager = new Dictionary>(); + + // Join to the specified room name + public async Task JoinGroup(ActionInfo info) + { + if (!userManager.ContainsKey(Context.ConnectionId)) + { + userManager.Add(Context.ConnectionId, info); + } + info.ConnectionId = Context.ConnectionId; + //Add the current connected use to the specified group + await Groups.AddToGroupAsync(Context.ConnectionId, info.RoomName); + if (groupManager.ContainsKey(info.RoomName)) + { + await Clients.Caller.SendAsync("dataReceived", "addUser", groupManager[info.RoomName]); + } + lock (groupManager) + { + if (groupManager.ContainsKey(info.RoomName)) + { + groupManager[info.RoomName].Add(info); + } + else + { + List actions = new List + { + info + }; + groupManager.Add(info.RoomName, actions); + } + } + // Notify other users in the group about new user joined the collaborative editing session. + Clients.GroupExcept(info.RoomName, Context.ConnectionId).SendAsync("dataReceived", "addUser", info); + } + +``` + +Handle user disconnection using SignalR. + +```csharp +//Handle disconnection from group. + public override Task OnDisconnectedAsync(Exception? e) + { + string roomName = userManager[Context.ConnectionId].RoomName; + if (groupManager.ContainsKey(roomName)) + { + groupManager[roomName].Remove(userManager[Context.ConnectionId]); + + if (groupManager[roomName].Count == 0) + { + groupManager.Remove(roomName); +//If all user disconnected from current room. Auto save the change to source document. +CollaborativeEditingController.UpdateOperationsToSourceDocument(roomName, “<>”, false); + } + } + + if (userManager.ContainsKey(Context.ConnectionId)) + { + //Notify other user in the group about user exit the collaborative editing session + Clients.OthersInGroup(roomName).SendAsync("dataReceived", "removeUser", Context.ConnectionId); + Groups.RemoveFromGroupAsync(Context.ConnectionId, roomName); + userManager.Remove(Context.ConnectionId); + } + return base.OnDisconnectedAsync(e); + } + +``` + +### Step 3: Configure Microsoft SQL database connection string in application level + +Configure the SQL database that stores temporary data for the collaborative editing session. Provide the SQL database connection string in `appsettings.json` file. + +```json +..... +"ConnectionStrings": { + "DocumentEditorDatabase": "" +} +..... + +``` + +### Step 4: Configure Web API actions for collaborative editing + +#### Import File + +1. When opening a document, create a database table to store temporary data for the collaborative editing session. +2. If the table already exists, retrieve the records from the table and apply them to the WordDocument instance using the `UpdateActions` method before converting it to the SFDT format. + +```csharp +public string ImportFile([FromBody] FileInfo param) + { + ..... + ..... + DocumentContent content = new DocumentContent(); + + ..... + //Get source document from database/file system/blob storage + WordDocument document = GetDocumentFromDatabase(param.fileName, param.documentOwner); + ..... + //Get temporary records from database + List actions = CreatedTable(param.fileName); + if(actions!=null) + { + //Apply temporary data to the document. + document.UpdateActions(actions); + } + string json = Newtonsoft.Json.JsonConvert.SerializeObject(document); + content.version = 0; + content.sfdt = json; + return Newtonsoft.Json.JsonConvert.SerializeObject(content); + } + +``` + +#### Update editing records to database. + +Each edit operation made by the user is sent to the server and is pushed to the database. Each operation receives a version number after being inserted into the database. +After inserting the records to the server, the position of the current editing operation must be transformed against any previous editing operations not yet synced with the client using the TransformOperation method. +After performing the transformation, the current operation is broadcast to all connected users within the group. + +```csharp +public async Task UpdateAction([FromBody] ActionInfo param) +{ + try + { + ActionInfo modifiedAction = AddOperationsToTable(param); + //After transformation broadcast changes to all users in the gropu + await _hubContext.Clients.Group(param.RoomName).SendAsync("dataReceived", "action", modifiedAction); + return modifiedAction; + } + catch + { + return null; + } +} + +private ActionInfo AddOperationsToTable(ActionInfo action) + { + int clientVersion = action.Version; + string tableName = action.RoomName; + ………… + ………… + ………… + ………… + List actions = GetOperationsQueue(table); + foreach (ActionInfo info in actions) + { + if (!info.IsTransformed) + { + CollaborativeEditingHandler.TransformOperation(info, actions); + } + } + action = actions[actions.Count - 1]; + action.Version = updateVersion; + //Return the transformed operation to broadcast it to other clients. + return action; + } + +``` + +#### Add Web API to get previous operation as a backup to get lost operations + +On the client side, messages broadcast using SignalR may be received in a different order, or some operations may be missed due to network issues. In these cases, we need a backup method to retrieve missing records from the database. +Using the following method, we can retrieve all operations after the last successful client-synced version and return all missing operations to the requesting client. + +```csharp +public async Task UpdateAction([FromBody] ActionInfo param) +{ + try + { + ActionInfo modifiedAction = AddOperationsToTable(param); + //After transformation broadcast changes to all users in the group + await _hubContext.Clients.Group(param.RoomName).SendAsync("dataReceived", "action", modifiedAction); + return modifiedAction; + } + catch + { + return null; + } +} + +private ActionInfo AddOperationsToTable(ActionInfo action) + { + int clientVersion = action.Version; + string tableName = action.RoomName; + ………… + ………… + ………… + ………… + List actions = GetOperationsQueue(table); + foreach (ActionInfo info in actions) + { + if (!info.IsTransformed) + { + CollaborativeEditingHandler.TransformOperation(info, actions); + } + } + action = actions[actions.Count - 1]; + action.Version = updateVersion; + //Return the transformed operation to broadcast it to other clients. + return action; + } + +``` +## How to perform Scaling in Collaborative Editing. + +As the number of user increases, maintaining responsiveness and performance becomes challenging. Scaling tackles this by distributing the workload across resources. You can scale the collaborative editing application using either ```Azure SignalR service or Redis backplane service``` + +### 1. Scaling with Azure SignalR + +Azure SignalR Service is a scalable, managed service for real-time communication in web applications. It enables real-time messaging between web clients (browsers) and your server-side application(across multiple servers). + +Below is a code snippet to configure Azure SignalR in an ASP.NET Core application using the ```AddAzureSignalR``` method + +```csharp +builder.Services.AddSignalR() .AddAzureSignalR("", options => { +// Specify the channel name +options.Channels.Add("document-editor"); + }); +``` + +### 2. Scaling with Redis backplane + +Using a Redis backplane, you achieve horizontal scaling of your SignalR application. The SignalR leverages Redis to efficiently broadcast messages across multiple servers. This allows your application to handle large user bases with minimal latency. + +In the SignalR app, install the following NuGet package: +* ` Microsoft.AspNetCore.SignalR.StackExchangeRedis` + +Below is a code snippet to configure Redis backplane in an ASP.NET Core application using the ```AddStackExchangeRedis ``` method + +```csharp +builder.Services.AddSignalR().AddStackExchangeRedis(""); +``` +Configure options as needed: + +The following example shows how to add a channel prefix in the ConfigurationOptions object. + +```csharp +builder.Services.AddDistributedMemoryCache().AddSignalR().AddStackExchangeRedis(connectionString, options => + { + options.Configuration.ChannelPrefix = "document-editor"; + }); +``` + + +Full version of the code discussed about can be found in below GitHub location. + +GitHub Example: [`Collaborative editing examples`](https://github.com/SyncfusionExamples/EJ2-Document-Editor-Collabrative-Editing) diff --git a/ej2-asp-core-mvc/document-editor/collaborative-editing/using-redis-cache-asp-net.md b/ej2-asp-core-mvc/document-editor/collaborative-editing/using-redis-cache-asp-net.md new file mode 100644 index 0000000000..090d71bca7 --- /dev/null +++ b/ej2-asp-core-mvc/document-editor/collaborative-editing/using-redis-cache-asp-net.md @@ -0,0 +1,415 @@ +--- +layout: post +title: Collaborative Editing in ##Platform_Name## Document Editor Control | Syncfusion +component: DocumentEditor +description: Learn how to enable and perform collaborative editing in Syncfusion ##Platform_Name## Document editor. +platform: ej2-asp-core-mvc +publishingplatform: ##Platform_Name## +documentation: ug +domainurl: ##DomainURL## +--- + +# Collaborative Editing + +Allows multiple users to work on the same document simultaneously. This can be done in real-time, so that collaborators can see the changes as they are made. Collaborative editing can be a great way to improve efficiency, as it allows team members to work together on a document without having to wait for others to finish their changes. + +## Prerequisites + +Following things are needed to enable collaborative editing in Document Editor + +- SignalR +- Redis + +## SignalR + +In collaborative editing, real-time communication is essential for users to see each other's changes instantly. We use a real-time transport protocol to efficiently send and receive data as edits occur. For this, we utilize SignalR, which supports real-time data exchange between the client and server. SignalR ensures that updates are transmitted immediately, allowing seamless collaboration by handling the complexities of connection management and offering reliable communication channels. + +To make SignalR work in a distributed environment (with more than one server instance), it needs to be configured with either Azure SignalR Service or a Redis backplane. + +### Scale-out SignalR using Azure SignalR service + +Azure SignalR Service is a scalable, managed service for real-time communication in web applications. It enables real-time messaging between web clients (browsers) and your server-side application(across multiple servers). + +Below is a code snippet to configure Azure SignalR in an ASP.NET Core application using the ```AddAzureSignalR``` method + +```csharp +builder.Services.AddSignalR() .AddAzureSignalR("", options => { + // Specify the channel name + options.Channels.Add("document-editor"); + }); +``` + +### Scale-out SignalR using Redis + +Using a Redis backplane, you can achieve horizontal scaling of your SignalR application. The SignalR leverages Redis to efficiently broadcast messages across multiple servers. This allows your application to handle large user bases with minimal latency. + +In the SignalR app, install the following NuGet package: +* ` Microsoft.AspNetCore.SignalR.StackExchangeRedis` + +Below is a code snippet to configure Redis backplane in an ASP.NET Core application using the ```AddStackExchangeRedis ``` method + +```csharp +builder.Services.AddSignalR().AddStackExchangeRedis(""); +``` +Configure options as needed: + +The following example shows how to add a channel prefix in the ConfigurationOptions object. + +```csharp +builder.Services.AddDistributedMemoryCache().AddSignalR().AddStackExchangeRedis(connectionString, options => + { + options.Configuration.ChannelPrefix = "document-editor"; + }); +``` + +## Redis + +In collaborative editing, Redis is used to store temporary data that helps queue editing operations and resolve conflicts using the `Operational Transformation` algorithm. + +All editing operations in collaborative editing are stored in the Redis cache. To prevent memory buildup, we can configure a `SaveThreshold` limit at the application level. If the `SaveThreshold` is 100, editing operations up to twice the save threshold limit are kept in Redis per document. Once exceeded, the first 100 operations (as defined by the save threshold) are removed from the cache and automatically saved to the source input document. + +The configuration and store size of the Redis cache can be adjusted based on the following considerations. + +- *Storage Requirements*: A minimum of 400KB of cache memory is needed for editing a single document, with the capacity to store up to 100 editing operations. Storage needs may increase based on following factor. + - *Images*: Increases with the number of images added to the document. + - *Pasted content*: Depends on the size of the SFDT content. +- *Connection Limits*: Redis has a limit on concurrent connections. Choose the Redis configuration based on your user base to ensure optimal performance. + +> For better performance, we recommend to have minimum `SaveThreshold` limit of 100. + +## How to enable collaborative editing in client side + +### Step 1: Enable collaborative editing in Document Editor + +To enable collaborative editing, inject `CollaborativeEditingHandler` and set the property `enableCollaborativeEditing` to true in the Document Editor, like in the code snippet below. + +{% if page.publishingplatform == "aspnet-core" %} + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/document-editor/collaborative-editing/tagHelper %} +{% endhighlight %} +{% highlight c# tabtitle="Document-editor.cs" %} +{% include code-snippet/document-editor/collaborative-editing/document-editor.cs %} +{% endhighlight %} +{% endtabs %} + +{% elsif page.publishingplatform == "aspnet-mvc" %} + +{% tabs %} +{% highlight razor tabtitle="CSHTML" %} +{% include code-snippet/document-editor/collaborative-editing/razor %} +{% endhighlight %} +{% highlight c# tabtitle="Document-editor.cs" %} +{% include code-snippet/document-editor/collaborative-editing/document-editor.cs %} +{% endhighlight %} +{% endtabs %} +{% endif %} + +## Step 2: Configure SignalR to send and receive changes + +To broadcast the changes made and receive changes from remote users, configure SignalR like below. + +{% if page.publishingplatform == "aspnet-core" %} + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/document-editor/collaborative-editing/script-1 %} +{% endhighlight %} +{% endtabs %} + +{% elsif page.publishingplatform == "aspnet-mvc" %} + +{% tabs %} +{% highlight razor tabtitle="CSHTML" %} +{% include code-snippet/document-editor/collaborative-editing/script-1 %} +{% endhighlight %} +{% endtabs %} +{% endif %} + +### Step 3: Join SignalR room while opening the document + +When opening a document, we need to generate a unique ID for each document. These unique IDs are then used to create rooms using SignalR, which facilitates sending and receiving data from the server. + +{% if page.publishingplatform == "aspnet-core" %} + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/document-editor/collaborative-editing/script-2 %} +{% endhighlight %} +{% endtabs %} + +{% elsif page.publishingplatform == "aspnet-mvc" %} + +{% tabs %} +{% highlight razor tabtitle="CSHTML" %} +{% include code-snippet/document-editor/collaborative-editing/script-2 %} +{% endhighlight %} +{% endtabs %} +{% endif %} + +### Step 5: Broadcast current editing changes to remote users + +Changes made on the client-side need to be sent to the server-side to broadcast them to other connected users. To send the changes made to the server, use the method shown below from the document editor using the `contentChange` event. + +{% if page.publishingplatform == "aspnet-core" %} + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/document-editor/collaborative-editing/script-3 %} +{% endhighlight %} +{% endtabs %} + +{% elsif page.publishingplatform == "aspnet-mvc" %} + +{% tabs %} +{% highlight razor tabtitle="CSHTML" %} +{% include code-snippet/document-editor/collaborative-editing/script-3 %} +{% endhighlight %} +{% endtabs %} +{% endif %} + +## How to enable collaborative editing in ASP.NET Core + +### Step 1: Configure SignalR in ASP.NET Core + +We are using Microsoft SignalR to broadcast the changes. Please add the following configuration to your application's Program.cs file. + +```csharp + using Microsoft.Azure.SignalR; + ..... + builder.Services.AddSignalR(); + ..... + ..... + ..... + app.MapHub("/documenteditorhub"); + ..... + ..... +``` + +### Step 2: Configure SignalR hub to create room for collaborative editing session + +To manage groups for each document, create a folder named "Hub" and add a file named "DocumentEditorHub.cs" inside it. Add the following code to the file to manage SignalR groups using room names. + +Join the group by using unique id of the document by using `JoinGroup` method. + +```csharp +static Dictionary userManager = new Dictionary(); + internal static Dictionary> groupManager = new Dictionary>(); + + // Join to the specified room name + public async Task JoinGroup(ActionInfo info) + { + if (!userManager.ContainsKey(Context.ConnectionId)) + { + userManager.Add(Context.ConnectionId, info); + } + info.ConnectionId = Context.ConnectionId; + //Add the current connected use to the specified group + await Groups.AddToGroupAsync(Context.ConnectionId, info.RoomName); + if (groupManager.ContainsKey(info.RoomName)) + { + await Clients.Caller.SendAsync("dataReceived", "addUser", groupManager[info.RoomName]); + } + lock (groupManager) + { + if (groupManager.ContainsKey(info.RoomName)) + { + groupManager[info.RoomName].Add(info); + } + else + { + List actions = new List + { + info + }; + groupManager.Add(info.RoomName, actions); + } + } + // Notify other users in the group about new user joined the collaborative editing session. + Clients.GroupExcept(info.RoomName, Context.ConnectionId).SendAsync("dataReceived", "addUser", info); + } + +``` + +Handle user disconnection using SignalR. + +```csharp +//Handle disconnection from group. + public override Task OnDisconnectedAsync(Exception? e) + { + string roomName = userManager[Context.ConnectionId].RoomName; + if (groupManager.ContainsKey(roomName)) + { + groupManager[roomName].Remove(userManager[Context.ConnectionId]); + + if (groupManager[roomName].Count == 0) + { + groupManager.Remove(roomName); +//If all user disconnected from current room. Auto save the change to source document. +CollaborativeEditingController.UpdateOperationsToSourceDocument(roomName, “<>”, false); + } + } + + if (userManager.ContainsKey(Context.ConnectionId)) + { + //Notify other user in the group about user exit the collaborative editing session + Clients.OthersInGroup(roomName).SendAsync("dataReceived", "removeUser", Context.ConnectionId); + Groups.RemoveFromGroupAsync(Context.ConnectionId, roomName); + userManager.Remove(Context.ConnectionId); + } + return base.OnDisconnectedAsync(e); + } + +``` + +### Step 3: Configure Redis cache connection string in application level + +Configure the Redis that stores temporary data for the collaborative editing session. Provide the Redis connection string in `appsettings.json` file. + +```json +..... +"ConnectionStrings": { + "RedisConnectionString": "<>" +} +..... + +``` + +### Step 4: Configure Web API actions for collaborative editing + +#### Import File + +1. When opening a document, check the Redis cache for pending operations and retrieve them for the collaborative editing session. +2. If pending operations exist, apply them to the WordDocument instance using the `UpdateActions` method before converting it to the SFDT format. + +```csharp +public string ImportFile([FromBody] FileInfo param) + { + ..... + ..... + DocumentContent content = new DocumentContent(); + + ..... + //Get source document from database/file system/blob storage + WordDocument document = GetSourceDocument(param.fileName); + ..... + //Get the temporary operations + List actions = await GetPendingOperations(param.fileName, 0, -1); + if(actions!=null && actions.Count > 0) + { + //Apply temporary data to the document. + document.UpdateActions(actions); + } + string json = Newtonsoft.Json.JsonConvert.SerializeObject(document); + content.version = 0; + content.sfdt = json; + return Newtonsoft.Json.JsonConvert.SerializeObject(content); + } + +``` + +#### Update editing records to Redis cache. + +Each edit operation made by the user is sent to the server and pushed into a Redis list data structure. Each operation is assigned a version number upon insertion into Redis. + +After inserting the records to the server, the position of the current editing operation must be transformed relative to any previous editing operations not yet synced with the client using the `TransformOperation` method to resolve any potential conflicts with the help of the `Operational Transformation` algorithm. + +Once the conflict is resolved, the current operation is broadcast to all connected users within the group. + +```csharp +public async Task UpdateAction([FromBody] ActionInfo param) +{ + try + { + ActionInfo modifiedAction = AddOperationsToCache(param); + //After transformation broadcast changes to all users in the gropu + await _hubContext.Clients.Group(param.RoomName).SendAsync("dataReceived", "action", modifiedAction); + return modifiedAction; + } + catch + { + return null; + } +} + +private ActionInfo AddOperationsToCache(ActionInfo action) + { + int clientVersion = action.Version; + string insertScript = "-------" + ………… + ………… + ………… + ………… + + IDatabase database = _redisConnection.GetDatabase(); + // Define the keys for Redis operations based on the action's room name + RedisKey[] keys = new RedisKey[] { action.RoomName + CollaborativeEditingHelper.VersionSuffix, action.RoomName, action.RoomName + CollaborativeEditingHelper.RevisionSuffix }; + // Serialize the action and prepare values for the Redis script + RedisValue[] values = new RedisValue[] { JsonConvert.SerializeObject(action), clientVersion.ToString(), CollaborativeEditingHelper.SaveThreshold.ToString() }; + // Execute the Lua script in Redis and store the results + RedisResult[] results = (RedisResult[])await database.ScriptEvaluateAsync(insertScript, keys, values); + + List previousOperations = ((RedisResult[])results[1]).Select(value => JsonConvert.DeserializeObject(value.ToString())).ToList(); + previousOperations.ForEach(op => op.Version = ++clientVersion); + if (previousOperations.Count > 1) + { + // Set the current action to the last operation in the list + action = previousOperations.Last(); + // Transform operations that have not been transformed yet + previousOperations.Where(op => !op.IsTransformed).ToList().ForEach(op => CollaborativeEditingHandler.TransformOperation(op, previousOperations)); + } + action = actions[actions.Count - 1]; + action.Version = updateVersion; + //Return the transformed operation to broadcast it to other clients. + return action; + } + +``` + +#### Add Web API to get previous operation as a backup to get lost operations + +On the client side, messages broadcast using SignalR might be received out of order or lost due to network issues. In such cases, we need a backup method to retrieve missing operations from Redis. By using the following method, we can retrieve all operations performed after the last successful client-synchronized version and return any missing operations to the requesting client. + +```csharp +public async Task GetActionsFromServer(ActionInfo param) + { + try + { + // Initialize necessary variables from the parameters and helper class + int saveThreshold = CollaborativeEditingHelper.SaveThreshold; + string tableName = param.RoomName; + int lastSyncedVersion = param.Version; + int clientVersion = param.Version; + + // Retrieve the database connection + IDatabase database = _redisConnection.GetDatabase(); + + // Fetch actions that are effective and pending based on the last synced version + List actions = await GetEffectivePendingVersion(tableName, lastSyncedVersion); + + // Increment the version for each action sequentially + actions.ForEach(action => action.Version = ++clientVersion); + + // Filter actions to only include those that are newer than the client's last known version + actions = actions.Where(action => action.Version > lastSyncedVersion).ToList(); + + // Transform actions that have not been transformed yet + actions.Where(action => !action.IsTransformed).ToList() + .ForEach(action => CollaborativeEditingHandler.TransformOperation(action, actions)); + + // Serialize the filtered and transformed actions to JSON and return + return Newtonsoft.Json.JsonConvert.SerializeObject(actions); + } + catch (Exception ex) + { + // In case of an exception, return an empty JSON object + return "{}"; + } + } + +``` + +Full version of the code discussed about can be found in below GitHub location. + +GitHub Example: [`Collaborative editing examples`](https://github.com/SyncfusionExamples/EJ2-Document-Editor-Collabrative-Editing) diff --git a/ej2-asp-core-mvc/document-editor/comments.md b/ej2-asp-core-mvc/document-editor/comments.md index db7e59d58c..aeae6d2a4d 100644 --- a/ej2-asp-core-mvc/document-editor/comments.md +++ b/ej2-asp-core-mvc/document-editor/comments.md @@ -18,7 +18,28 @@ Document editor allows to add comments to documents. You can add, navigate and r Comments can be inserted to the selected text. ```typescript -documentEditor.editor.insertComment("Test comment"); +documentEditor.editor.insertComment('Test comment'); +``` + +## Add a New Comment with Date, Author, and Status + +Comments can be inserted into the selected text with a specified date, author, and status. + +```typescript +// In this example, a comment with the text "Nancy Davolio" is added by the author Rachel Green on July 23, 2024, at 2:30 PM. The isResolved status is set to false. + +// Create a specific date: July 23, 2024, at 2:30:00 PM. +let specificDate = new Date(2024, 6, 23, 14, 30, 0); // Note: July is represented by 6 (0-based index). + +// Define the properties of the comment including author, date, and resolution status. +let commentProperties = { + author: 'Nancy Davolio', // The author of the comment. + dateTime: specificDate, // The date and time when the comment is created. + isResolved: false // The status of the comment; false indicates it is unresolved. +}; + +// Insert the comment with the specified properties into the document editor. +documentEditor.editor.insertComment('Hello world', commentProperties); ``` ## Add a New Comment with Date, Author, and Status diff --git a/ej2-asp-core-mvc/document-editor/overview.md b/ej2-asp-core-mvc/document-editor/overview.md index 41364f1ed6..04e4d3443c 100644 --- a/ej2-asp-core-mvc/document-editor/overview.md +++ b/ej2-asp-core-mvc/document-editor/overview.md @@ -36,11 +36,11 @@ The Document Editor component is used to create, edit, view, and print Word docu ## Supported Web platforms -* [Javascript(ES5)](https://ej2.syncfusion.com/javascript/documentation/document-editor/getting-started/) -* [Javascript](https://ej2.syncfusion.com/documentation/document-editor/getting-started/) -* [Angular](https://ej2.syncfusion.com/angular/documentation/document-editor/getting-started/) -* [React](https://ej2.syncfusion.com/react/documentation/document-editor/getting-started/) -* [Vue](https://ej2.syncfusion.com/vue/documentation/document-editor/getting-started/) -* [ASP.NET Core](https://ej2.syncfusion.com/aspnetcore/documentation/document-editor/getting-started-core/) -* [ASP.NET MVC](https://ej2.syncfusion.com/aspnetmvc/documentation/document-editor/getting-started/) -* [Blazor](https://blazor.syncfusion.com/documentation/document-editor/getting-started/server-side-application/) \ No newline at end of file +* [Javascript(ES5)](https://ej2.syncfusion.com/javascript/documentation/document-editor/getting-started) +* [Javascript](https://ej2.syncfusion.com/documentation/document-editor/getting-started) +* [Angular](https://ej2.syncfusion.com/angular/documentation/document-editor/getting-started) +* [React](https://ej2.syncfusion.com/react/documentation/document-editor/getting-started) +* [Vue](https://ej2.syncfusion.com/vue/documentation/document-editor/getting-started) +* [ASP.NET Core](https://ej2.syncfusion.com/aspnetcore/documentation/document-editor/getting-started-core) +* [ASP.NET MVC](https://ej2.syncfusion.com/aspnetmvc/documentation/document-editor/getting-started) +* [Blazor](https://blazor.syncfusion.com/documentation/document-editor/getting-started/server-side-application) \ No newline at end of file diff --git a/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/cell.md b/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/cell.md index 7b4823c3e6..953c8c8d1c 100644 --- a/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/cell.md +++ b/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/cell.md @@ -8,9 +8,9 @@ publishingplatform: ##Platform_Name## documentation: ug --- -# Cell in ##Platform_Name## Grid component +# Cell in ASP.NET MVC Grid component -In the Syncfusion ##Platform_Name## Grid, a **cell** refers to an individual data point or a unit within a grid column that displays data. It represents the intersection of a row and a column, and it contains specific information associated with that row and column. Each cell can display text, numbers, or other content related to the data it represents. +In the Syncfusion ASP.NET MVC Grid, a **cell** refers to an individual data point or a unit within a grid column that displays data. It represents the intersection of a row and a column, and it contains specific information associated with that row and column. Each cell can display text, numbers, or other content related to the data it represents. The Grid component allows you to customize the appearance and behavior of cells using various features and options. You can define templates, format cell values, enable or disable editing, and perform various other operations on the cells to create interactive and informative data grids in your web applications. diff --git a/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/columns/auto-generated-columns.md b/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/columns/auto-generated-columns.md deleted file mode 100644 index 03d3797628..0000000000 --- a/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/columns/auto-generated-columns.md +++ /dev/null @@ -1,103 +0,0 @@ ---- -layout: post -title: Auto Generated Columns in ##Platform_Name## Grid Component -description: Learn here all about Auto Generated Columns in Syncfusion ##Platform_Name## Grid component of Syncfusion Essential JS 2 and more. -platform: ej2-asp-core-mvc -control: Auto Generated Columns -publishingplatform: ##Platform_Name## -documentation: ug ---- - -# Auto Generated Columns - -The [`Columns`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html) are automatically generated when [`Columns`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html) declaration is empty or undefined while initializing the grid. All the columns in the [`DataSource`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_DataSource) are bound as grid columns. - -{% if page.publishingplatform == "aspnet-core" %} - -{% tabs %} -{% highlight cshtml tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/auto/tagHelper %} -{% endhighlight %} -{% highlight c# tabtitle="Auto.cs" %} -{% include code-snippet/grid/columns/auto/auto.cs %} -{% endhighlight %} -{% endtabs %} - -{% elsif page.publishingplatform == "aspnet-mvc" %} - -{% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/auto/razor %} -{% endhighlight %} -{% highlight c# tabtitle="Auto.cs" %} -{% include code-snippet/grid/columns/auto/auto.cs %} -{% endhighlight %} -{% endtabs %} -{% endif %} - - - -N> When columns are auto-generated, the column [`Type`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html#Syncfusion_EJ2_Grids_GridColumn_Type) will be determined from the first record of the [`DataSource`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_DataSource). - -## Set Primary key column for auto generated columns when editing is enabled - -Primary key can be defined in the declaration of column object of the grid. When you did not declare the columns, the grid will generate the columns automatically. For these auto generated columns, you can set [`IsPrimaryKey`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html#Syncfusion_EJ2_Grids_GridColumn_IsPrimaryKey) column property as true by using the following ways, - -If Primary key "column index" is known then refer the following example - -{% if page.publishingplatform == "aspnet-core" %} - -{% tabs %} -{% highlight cshtml tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/primary/tagHelper %} -{% endhighlight %} -{% highlight c# tabtitle="Primary.cs" %} -{% include code-snippet/grid/columns/primary/primary.cs %} -{% endhighlight %} -{% endtabs %} - -{% elsif page.publishingplatform == "aspnet-mvc" %} - -{% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/primary/razor %} -{% endhighlight %} -{% highlight c# tabtitle="Primary.cs" %} -{% include code-snippet/grid/columns/primary/primary.cs %} -{% endhighlight %} -{% endtabs %} -{% endif %} - - - -N> If Primary key "column fieldname" is known then you can get the column by using **var column = grid.getColumnByField('OrderID')** and then set primary key by defining **Column.IsPrimaryKey = 'true'** - -## Set column options to auto generated columns - -You can set column options such as [`Format`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html#Syncfusion_EJ2_Grids_GridColumn_Format), [`Width`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html#Syncfusion_EJ2_Grids_GridColumn_Width) to the auto generated columns by using [`DataBound`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_DataBound) event of the grid. - -In the below example, [`Width`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html#Syncfusion_EJ2_Grids_GridColumn_Width) is set for **OrderID** column, date type is set for **OrderDate** column and numeric type is set for **Freight** column. - -{% if page.publishingplatform == "aspnet-core" %} - -{% tabs %} -{% highlight cshtml tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/autocolumnformat/tagHelper %} -{% endhighlight %} -{% highlight c# tabtitle="Autocolumnformat.cs" %} -{% include code-snippet/grid/columns/autocolumnformat/autocolumnformat.cs %} -{% endhighlight %} -{% endtabs %} - -{% elsif page.publishingplatform == "aspnet-mvc" %} - -{% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/autocolumnformat/razor %} -{% endhighlight %} -{% highlight c# tabtitle="Autocolumnformat.cs" %} -{% include code-snippet/grid/columns/autocolumnformat/autocolumnformat.cs %} -{% endhighlight %} -{% endtabs %} -{% endif %} - diff --git a/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/columns/column-chooser.md b/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/columns/column-chooser.md index 262c04ac53..cd1e7fbe2a 100644 --- a/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/columns/column-chooser.md +++ b/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/columns/column-chooser.md @@ -8,62 +8,118 @@ publishingplatform: ##Platform_Name## documentation: ug --- -# Column Chooser +# Column chooser in ASP.NET MVC Grid component -The column chooser has options to show or hide columns dynamically. It can be enabled by defining the [`ShowColumnChooser`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ShowColumnChooser) as true. - -{% if page.publishingplatform == "aspnet-core" %} +The column chooser feature in the Syncfusion ASP.NET MVC Grid component allows you to dynamically show or hide columns. This feature can be enabled by defining the [ShowColumnChooser](https://help.syncfusion.com/cr/aspnetmvc-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_ShowColumnChooser) property as **true**. {% tabs %} {% highlight cshtml tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/columnchooser/tagHelper %} +{% include code-snippet/grid/columns/columnchooser/razor %} {% endhighlight %} {% highlight c# tabtitle="Columnchooser.cs" %} {% include code-snippet/grid/columns/columnchooser/columnchooser.cs %} {% endhighlight %} {% endtabs %} -{% elsif page.publishingplatform == "aspnet-mvc" %} +![Column chooser](../../images/column-chooser/Colum-chooser.png) + +> The column chooser dialog displays the header text of each column by default. If the header text is not defined for a column, the corresponding column field name is displayed instead. + +## Hide column in column chooser dialog + +You can hide the column names in column chooser by defining the `Columns.ShowInColumnChooser` as **false**. This feature is useful when working with a large number of columns or when you want to limit the number of columns that are available for selection in the column chooser dialog. + +In this example, the `Columns.ShowInColumnChooser` property is set to **false** for the **Order ID** column. As a result, the **Order ID** column will not be displayed in the column chooser dialog. {% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/columnchooser/razor %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/columnchooser-hide/razor %} {% endhighlight %} {% highlight c# tabtitle="Columnchooser.cs" %} -{% include code-snippet/grid/columns/columnchooser/columnchooser.cs %} +{% include code-snippet/grid/columns/columnchooser-hide/columnchooser.cs %} {% endhighlight %} {% endtabs %} -{% endif %} +![Hide column in column chooser dialog](../../images/column-chooser/Colum-chooser-hide.png) +>The `Columns.ShowInColumnChooser` property is applied to each column element individually. By setting it to **false**, you can hide specific columns from the column chooser dialog. -N> You can hide the column names in column chooser by defining the [`ShowInColumnChooser`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html#Syncfusion_EJ2_Grids_GridColumn_ShowInColumnChooser) as false. +## Open column chooser by externally + +The Syncfusion ASP.NET MVC Grid provides the flexibility to open the column chooser dialog on a web page using an external button. By default, the column chooser button is displayed in the right corner of the grid component, and clicking the button opens the column chooser dialog below it. However, you can programmatically open the column chooser dialog at specific **X** and **Y** axis positions by using the `openColumnChooser` method. + +Here's an example of how to open the column chooser in the Grid using an external button: + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/columnchooser-external/razor %} +{% endhighlight %} +{% highlight c# tabtitle="Columnchooser.cs" %} +{% include code-snippet/grid/columns/columnchooser-external/columnchooser.cs %} +{% endhighlight %} +{% endtabs %} -## Open column chooser by external button +![Open column chooser by externally](../../images/column-chooser/Colum-chooser-external.png) -The Column chooser can be displayed on a page through external button by invoking the **openColumnChooser** method with X and Y axis positions. +## Customize column chooser dialog size + +The column chooser dialog in Syncfusion ASP.NET MVC Grid comes with default size, but you can modify its height and width as per your specific needs using CSS styles. +To customize the column chooser dialog size, you can use the following CSS styles: -{% if page.publishingplatform == "aspnet-core" %} +```css +.e-grid .e-dialog.e-ccdlg { + height: 500px; + width: 200px; +} +.e-grid .e-ccdlg .e-cc-contentdiv { + height: 200px; + width: 230px; +} +``` {% tabs %} {% highlight cshtml tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/externalbutton/tagHelper %} +{% include code-snippet/grid/columns/columnchooser-size/razor %} {% endhighlight %} -{% highlight c# tabtitle="Externalbutton.cs" %} -{% include code-snippet/grid/columns/externalbutton/externalbutton.cs %} +{% highlight c# tabtitle="Columnchooser.cs" %} +{% include code-snippet/grid/columns/columnchooser-size/columnchooser.cs %} {% endhighlight %} {% endtabs %} -{% elsif page.publishingplatform == "aspnet-mvc" %} +![Customize column chooser dialog size](../../images/column-chooser/Colum-chooser-size.png) + +## Change default search operator of the column chooser + +The column chooser dialog in the Syncfusion ASP.NET MVC Grid provides a search box that allows you to search for column names. By default, the search functionality uses the "startsWith" operator to match columns and display the results in the column chooser dialog. However, there might be cases where you need to change the default search operator to achieve more precise data matching. + +To change the default search operator of the column chooser in Syncfusion Grid, you need to use the [operator](https://help.syncfusion.com/cr/aspnetmvc-js2/Syncfusion.EJ2.Grids.GridColumnChooserSettings.html#Syncfusion_EJ2_Grids_GridColumnChooserSettings_Operator) property of the columnChooserSettings. + +Here's an example of how to change the default search operator of the column chooser to **contains** in the ASP.NET MVC Grid: {% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/externalbutton/razor %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/columnchooser-contains/razor %} {% endhighlight %} -{% highlight c# tabtitle="Externalbutton.cs" %} -{% include code-snippet/grid/columns/externalbutton/externalbutton.cs %} +{% highlight c# tabtitle="Columnchooser.cs" %} +{% include code-snippet/grid/columns/columnchooser-contains/columnchooser.cs %} {% endhighlight %} {% endtabs %} -{% endif %} +![Change default search operator of the column chooser ](../../images/column-chooser/Colum-chooser-contains.png) + +## Diacritics searching in column chooser + +By default, the grid ignores diacritic characters when performing a search in the column chooser. However, in some cases, you may want to include diacritic characters in the search. To enable this behavior, you can set the [Columnchoosersettings.IgnoreAccent](https://help.syncfusion.com/cr/aspnetmvc-js2/Syncfusion.EJ2.Grids.GridColumnChooserSettings.html#Syncfusion_EJ2_Grids_GridColumnChooserSettings_IgnoreAccent) property to **true**. + +Here is an example that demonstrates the usage of the `IgnoreAccent` property to include diacritic characters for searching in the column chooser: + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/columnchooser-diacritics/razor %} +{% endhighlight %} +{% highlight c# tabtitle="Columnchooser.cs" %} +{% include code-snippet/grid/columns/columnchooser-diacritics/columnchooser.cs %} +{% endhighlight %} +{% endtabs %} +![Diacritics searching in column chooser](../../images/columns/Column-headertext.png) diff --git a/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/columns/column-headers.md b/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/columns/column-headers.md new file mode 100644 index 0000000000..51b68ea80f --- /dev/null +++ b/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/columns/column-headers.md @@ -0,0 +1,474 @@ +--- +layout: post +title: Headers in ##Platform_Name## Grid Component +description: Learn here all about Headers in Syncfusion ##Platform_Name## Grid component of Syncfusion Essential JS 2 and more. +platform: ej2-asp-core-mvc +control: Headers +publishingplatform: ##Platform_Name## +documentation: ug +--- + +# Headers in ASP.NET MVC Grid component + +The Syncfusion ASP.NET MVC Grid component provides a comprehensive set of options to customize and manage headers efficiently. Headers play a crucial role in organizing and presenting data effectively in the grid. + +## Header text + +The `HeaderText` feature proves particularly beneficial when there is a need for more meaningful and descriptive column headers in the Syncfusion ASP.NET MVC Grid component. + +By default, the header text of a column in Grid is displayed from the column's `Field` value. However, you can easily override the default header title and provide a custom header text for the column using the `HeaderText` property. + +To enable the `HeaderText` property, you simply need to define it in the **e-grid-column** element. The following example demonstrates how to enable header text for a Grid column. + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/headertext/razor %} +{% endhighlight %} +{% highlight c# tabtitle="Headertext.cs" %} +{% include code-snippet/grid/columns/headertext/headertext.cs %} +{% endhighlight %} +{% endtabs %} + +![Header text](../../images/columns/Column-headertext.png) + +> * If both the `Field` and `HeaderText` are not defined in the column, the column renders with **empty** header text. +> * The `HeaderText` property is optional, and if it is not defined, then the corresponding column's field value is set as header text for that column. +> * You can also use the `HeaderTemplate` property to apply custom HTML content to the header cell. + +## Header template + +The header template feature in the Syncfusion ASP.NET MVC Grid component allows you to create custom header layouts and content, providing enhanced functionality such as sorting or filtering. + +To implement a header template, set the `HeaderTemplate` property within a specific column definition. This allows you to render custom HTML elements or ASP.NET MVC components to the header. + +The following example demonstrate, the custom element is rendered for both **CustomerID**,**Freight** and **OrderDate** column headers. + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/headertemplate/razor %} +{% endhighlight %} +{% highlight c# tabtitle="Headertemplate.cs" %} +{% include code-snippet/grid/columns/headertemplate/headertemplate.cs %} +{% endhighlight %} +{% endtabs %} + +![Header template](../../images/columns/Column-headertext-headerTemplate.png) + +>* The `HeaderTemplate` property is only applicable to Grid columns that have a header element. +>* You can use any HTML or ASP.NET MVC component in the header template to add additional functionality to the header element. + +## Stacked header + +In Grid, you can group multiple levels of column headers by stacking the Grid columns. This feature allows you to organize the Grid columns in a more structured and understandable way. This can be achieved by setting the [columns->columns](https://help.syncfusion.com/cr/aspnetmvc-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_Columns) property. Within this property, you can define an array of column objects to group together as sub-headers under a main header. You can define the `HeaderText` property of each sub-header column to set the text for that sub-header. + +You can customize the appearance of the stacked header elements by using the `HeaderTemplate` property. This allows you to render custom HTML elements or ASP.NET MVC components to the header. + +Here's an example of how to use stacked headers with a custom `HeaderTemplate` in Syncfusion Grid. + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/headertext-stacked/razor %} +{% endhighlight %} +{% highlight c# tabtitle="Stackedheader.cs" %} +{% include code-snippet/grid/columns/headertext-stacked/stackedHeader.cs %} +{% endhighlight %} +{% endtabs %} + +![Stacked header](../../images/columns/Column-headertext-stacked.png) + +## Align the text of header text + +You can horizontally align the text in column headers of the Grid component using the `HeaderTextAlign` property. By default, the text is aligned to the left, but you can change the alignment by setting the value of the `HeaderTextAlign` property to one of the following options: + +* **Left**: Aligns the text to the left (default). +* **Center**: Aligns the text to the center. +* **Right**: Aligns the text to the right. +* **Justify**: Header text is justified. + +The following example demonstrates how to dynamically change the alignment of the header text based on DropDown change: + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/headertext-textalign/razor %} +{% endhighlight %} +{% highlight c# tabtitle="Headertext.cs" %} +{% include code-snippet/grid/columns/headertext-textalign/headertext.cs %} +{% endhighlight %} +{% endtabs %} + +![Align the text of header text](../../images/columns/Column-headertext-change-alignment.gif) + +>* The `HeaderTextAlign` property only changes the alignment of the text in the column header, and not the content of the column. If you want to align both the column header and content, you can use the [TextAlign](https://help.syncfusion.com/cr/aspnetmvc-js2/Syncfusion.EJ2.Grids.TextAlign.html) property. +>* You can also use the `HeaderTextAlign` property with the stacked header feature in Syncfusion Grid. The property will align the header text in the sub-headers as well. + +## Autowrap the header text + +The autowrap allows the cell content of the grid to wrap to the next line when it exceeds the boundary of the specified cell width. The cell content wrapping works based on the position of white space between words. To support the Autowrap functionality in Syncfusion Grid, you should set the appropriate [Width](https://help.syncfusion.com/cr/aspnetmvc-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_Width) for the columns. The column width defines the maximum width of a column and helps to wrap the content automatically. + +To enable autowrap, set the [AllowTextWrap](https://help.syncfusion.com/cr/aspnetmvc-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_AllowTextWrap) property to **true**. You can also configure the auto wrap mode by setting the [TextWrapSettings.WrapMode](https://help.syncfusion.com/cr/aspnetmvc-js2/Syncfusion.EJ2.Grids.GridTextWrapSettings.html#Syncfusion_EJ2_Grids_GridTextWrapSettings_WrapMode) property. + +Grid provides the below three options for configuring: + +* **Both**: This is the default value for wrapMode. With this option, both the grid header text and content is wrapped. +* **Header**: With this option, only the grid header text is wrapped. +* **Content**: With this option, only the grid content is wrapped. + +>* If a column width is not specified, then the Autowrap of columns will be adjusted with respect to the grid's width. +>* If a column's header text contains no white space, the text may not be wrapped. +>* If the content of a cell contains HTML tags, the Autowrap functionality may not work as expected. In such cases, you can use the `HeaderTemplate` and `Template` properties of the column to customize the appearance of the header and cell content. + +The following example demonstrates how to dynamically change the auto-wrap of the header text based on DropDown change. + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/headertext-autowrap/razor %} +{% endhighlight %} +{% highlight c# tabtitle="Headertext.cs" %} +{% include code-snippet/grid/columns/headertext-autowrap/headertext.cs %} +{% endhighlight %} +{% endtabs %} + +![Autowrap the header text](../../images/columns/Column-headertext-wrap-mode.png) + +## Change the height of header + +Changing the height of the header can be useful in cases where the default height is not sufficient to display the header content cell. For example, if you have a header with a lot of text or if you want to add an image to the header, you may need to increase the height of the header to accommodate the content.This can be easily achieved by changing the height of the header using CSS or by dynamically adjusting the height using a methods. + +**Using css** + +You can use CSS to override the default height of the **.e-grid .e-headercell** class to change the height of the header. Here is an example code snippet: + +```css +.e-grid .e-headercell { + height: 130px; +} +``` + +**Using methods** + +To change the height of the header dynamically, you can use the `getHeaderContent` method to get the header content element of the Syncfusion Grid. Then, you can use the **querySelectorAll** method to get all the header cell elements with the class **e-headercell**. Finally, you can loop through each header cell element and set its style property to adjust the height. + +The following example demonstrates how to dynamically change the height of the header based on a Button `click` event. + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/headertext-change-height/razor %} +{% endhighlight %} +{% highlight c# tabtitle="Headertext.cs" %} +{% include code-snippet/grid/columns/headertext-change-height/headertext.cs %} +{% endhighlight %} +{% endtabs %} + +![Change the height of header](../../images/columns/Column-headertext-change-height.gif) + +>* You can also use the `GetHeaderTable` method to get the table element of the header, and then adjust the height. +>* You cannot change the height of row below the default height of 42px using the **e-columnheader** class. + +## Change header text dynamically + +The Syncfusion Grid component provides a way to modify the header text of a corresponding column in real-time based on events or other events. This feature can be useful in various scenarios, such as displaying a custom header text for a specific column or updating the header text dynamically based on input. By allowing for dynamic changes to the header text, the Grid provides a more flexible and customizable experience. + +**Using Event** + +To modify the header text of a corresponding column dynamically, you can use the [HeaderCellInfo](https://help.syncfusion.com/cr/aspnetmvc-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_HeaderCellInfo) event provided by the Syncfusion Grid. This event is triggered for each header cell element rendered in the Grid. + +When the `HeaderCellInfo` event is triggered, it provides a **HeaderCellInfoEventArgs** object as a parameter. This object contains the following properties: + +* **cell**: Defines the header cell that is being modified. +* **node**: Defines the DOM element of the header cell that is being modified. + +You can use these properties to access and modify the header text of the corresponding column. Once the header text is modified, you can refresh the Grid to reflect the changes by calling the `refreshHeader` method of the Grid. + +**Using method** + +The Grid component provides several methods that allow you to change the column header text dynamically. Here are some of the methods you can use: + +1. `getColumnByField`: This method takes a field name as a parameter and returns the entire column object that corresponds to that field name, including properties such as headerText, width, and alignment. You can use this method to modify any aspect of the column. + +2. `getColumnHeaderByField`: Retrieves the header element of a column based on its field name. You can modify the **textContent** property of the header element to change the header text. This method does not return a reference to the column object itself, only to the header element. + +3. `getColumnIndexByField`: Retrieves the index of a column based on its field name. You can then use the `getColumnByIndex` method to retrieve the column object and modify its `HeaderText` property to change the header text. + +4. `getColumnByUid`: Retrieves the column object based on its unique identifier (UID). You can modify the `HeaderText` property of the column object to change the header text. + +5. `getColumnHeaderByIndex`: Retrieves the header element of a column based on its zero-based index. You can modify the **textContent** property of the header element to change the header text. This method does not return a reference to the column object itself, only to the header element. + +6. `getColumnIndexByUid`: Retrieves the index of a column based on its unique identifier (UID). You can then use the `getColumnByIndex` method to retrieve the column object and modify its `HeaderText` property to change the header text. + +7. `getColumnHeaderByUid`: Retrieves the header element of a column based on its unique identifier (UID). You can modify the **textContent** property of the header element to change the header text. This method does not return a reference to the column object itself, only to the header element.If you only have an `Template` for the column header, and the column itself is not defined with a `Field` , then you can use the `getColumnHeaderByUid` method to get a reference to the header element and modify its text content to change the header text. + +>* When you change the header text dynamically, you need to **refresh** the Grid to reflect the changes by calling the `refreshHeader` method. +>* The UID is automatically generated by the Grid component and may change whenever the grid is refreshed or updated. + +Here is an example of how to change the header text of a column using the `getColumnByField` method: + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/headertext-change/razor %} +{% endhighlight %} +{% highlight c# tabtitle="Columntext.cs" %} +{% include code-snippet/grid/columns/headertext-change/columntext.cs %} +{% endhighlight %} +{% endtabs %} + +![Change header text dynamically](../../images/columns/Column-headertext-change.png) + + +**Changing the header text of all columns** + +If you want to change the header text of all columns in the grid, you can loop through the Columns collection of the grid and set the `headerText` property for each column. Here is an example: + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/headertext-change-all/razor %} +{% endhighlight %} +{% highlight c# tabtitle="Columntext.cs" %} +{% include code-snippet/grid/columns/headertext-change-all/columntext.cs %} +{% endhighlight %} +{% endtabs %} + +![Changing the header text of all columns](../../images/columns/Column-headertext-change-all.gif) + +## Change the orientation of header text + +By default, the text in the column headers of the Syncfusion Grid control is oriented horizontally. However, in some cases, you may want to change the orientation of the header text to vertical, diagonal, or at a custom angle. This can be achieved by adding a custom CSS class to the column header cell using the `CustomAttributes` property of the Grid columns. + +Follow the below steps to change the orientation of the header text in Grid: + +**Step 1**: **Create a CSS class with orientation style for grid header cell** + +To `rotate` the header text, you can create a CSS class with the `transform` property that rotates the header text 90 degrees. This class will be added to the header cell using the `CustomAttributes` property. + +```css +.orientationcss .e-headercelldiv { + transform: rotate(90deg); +} +``` + +**Step 2**: **Add the custom CSS class to the grid column** + +Once you have created the CSS class, you can add it to the particular column by using the `CustomAttributes` property. This property allows you to add any custom attribute to the grid column. + +For example, to add the orientationcss class to the Freight column, you can use the following code: + +```typescript + col.Field("Freight").HeaderText("Freight").Width("120").Format("C").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Center).CustomAttributes(new { @class = "orientationcss" }).Add(); +``` + +**Step 3**: **Resize the header cell height** + +After adding the custom CSS class to a column, you need to resize the header cell height so that the rotated header text is fully visible. You can do this by using the following code: + +```typescript + + function setHeaderHeight(args) { + var textWidth = document.querySelector(".orientationcss > div").scrollWidth; // obtain the width of the headerText content. + var headerCell = document.querySelectorAll(".e-headercell"); + for (var i = 0; i < headerCell.length; i++) { + headerCell.item(i).style.height = textWidth + 'px'; // assign the obtained textWidth as the height of the headerCell. + } + } + +``` + +The following example demonstrates how to change the orientation of the **Freight** column header text to 90 degrees: + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/headertext-orientation/razor %} +{% endhighlight %} +{% highlight c# tabtitle="Headertext.cs" %} +{% include code-snippet/grid/columns/headertext-orientation/headertext.cs %} +{% endhighlight %} +{% endtabs %} + +![Change the orientation of header text](../../images/columns/Column-headertext-orientation.png) + +## Custom tooltip for header + +Custom tooltips for headers provide additional information when hovering over a column header in the Syncfusion Grid. This can be useful in situations where there is not enough space to display all of the information related to a column, or when there is additional context that may be helpful. + +To enable custom tooltips for headers, you can use the `BeforeRender` event of the Grid component. This event is triggered for each header cell before it is rendered, allowing you to add a custom tooltip to the header cell using `tooltip` component. + +Here's an example of how to use the `BeforeRender` event to add a custom tooltip to a header cell: + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/headertext-tooltip/razor %} +{% endhighlight %} +{% highlight c# tabtitle="Headertext.cs" %} +{% include code-snippet/grid/columns/headertext-tooltip/headertext.cs %} +{% endhighlight %} +{% endtabs %} + +![Custom tooltip for header](../../images/columns/Column-headertext-tooltip.png) + +> * The [HeaderCellInfo](https://help.syncfusion.com/cr/aspnetmvc-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_HeaderCellInfo) event can also be used to customize the header tooltip. This event is triggered for each header cell after it is rendered. + +## Customize header text styles + +Customizing the grid header styles allows you to modify the appearance of the column header in the Grid control to meet your design requirements. You can customize the font, background color, and other styles of the header cells. To customize the header styles in the grid, you can use CSS, properties, methods, or event support provided by the Syncfusion ASP.NET MVC Grid component. + +### Using CSS + +You can apply styles to the header cells using CSS selectors. The Grid provides a class name for each header cell element, which you can use to apply styles to that specific header cell. The **.e-headercell** class can be used to change the background color and text color of the column header. + +```CSS + .e-grid .e-headercell { + background-color: #a2d6f4; + color:rgb(3, 2, 2); + } +``` +Here's an example that demonstrates how to customize the appearance of a column header in the Grid using **className**. + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/headertext-using-css/razor %} +{% endhighlight %} +{% highlight c# tabtitle="Headertext.cs" %} +{% include code-snippet/grid/columns/headertext-using-css/headertext.cs %} +{% endhighlight %} +{% endtabs %} + +![Display HTML content](../../images/columns/Column-headertext-using-css.png) + +### Using property + +You can customize the appearance of the column headers in Grid using the `CustomAttributes` property. The `CustomAttributes` property takes an object with the name-value pair to customize the CSS properties for grid header cells. You can also set multiple CSS properties to the custom class using the `CustomAttributes` property. + +To customize the header of a column, you can follow the steps below: + +Step 1: Define a CSS class that specifies the styles you want to apply to the header cell of the column. For example, to change the background color and text color of the header cell, define a CSS class like this: + + ```CSS + .e-grid .e-headercell.customcss { + background-color: rgb(43, 205, 226); + color: black; + } + + ``` + +Step 2: Set the **CustomAttributes** property of the desired column to an object that contains the CSS class **customcss**. This CSS class will be applied to the header cell of the specified column in the Grid. + + ```ts + col.Field("Freight").HeaderText("Freight").Width("120").CustomAttributes(new { @class = "customcss" }).Format("C").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); + ``` + +The following example demonstrates how to customize the appearance of the **OrderID** and **OrderDate** columns using custom attributes. + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/headertext-using-property/razor %} +{% endhighlight %} +{% highlight c# tabtitle="Headertext.cs" %} +{% include code-snippet/grid/columns/headertext-using-property/headertext.cs %} +{% endhighlight %} +{% endtabs %} + +![Using property](../../images/columns/Column-headertext-using-property.png) + +### Using method + +The Syncfusion Grid provides methods to customize the appearance of the grid columns header. + +1. `getColumnHeaderByIndex`: The method is used to customize the appearance of a specific column header in the grid by specifying the index of the column for which you want to customize the header. + +2. `getColumnHeaderByField`: This method is used to retrieve the header element of a specific column by its field name. You can use the retrieved element to customize the appearance of the header element. +3. `getColumnHeaderByUid`: This method is used to retrieve the header element of a specific column by its unique ID. You can use the retrieved element to customize the appearance of the header element. + + 4. `getColumnIndexByField`:This method is used to retrieve the index of a specific column by its field name. You can use the retrieved index to access the header element and customize its appearance. + + 5. `getColumnIndexByUid`: This method is used to retrieve the index of a specific column by its unique ID. You can use the retrieved index to access the header element and customize its appearance. + +Here's an example of how to use these methods to change the style of a specific column header: + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/headertext-using-method/razor %} +{% endhighlight %} +{% highlight c# tabtitle="Headertext.cs" %} +{% include code-snippet/grid/columns/headertext-using-method/headertext.cs %} +{% endhighlight %} +{% endtabs %} + +![Using method](../../images/columns/Column-headertext-using-method.png) + +>* The UID is automatically generated by the Grid component and may change whenever the grid is refreshed or updated. + +### Using event + +To customize the appearance of the grid header, you can handle the [HeaderCellInfo](https://help.syncfusion.com/cr/aspnetmvc-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_HeaderCellInfo) event of the grid. This event is triggered when each header cell is rendered in the grid, and provides an object that contains information about the header cell. You can use this object to modify the styles of the header column. + +The following example demonstrates how to add a `HeaderCellInfo` event handler to the grid. In the event handler, checked whether the current header column is **Order Date** field and then applied the appropriate CSS class to the cell based on its value. + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/headertext-using-event/razor %} +{% endhighlight %} +{% highlight c# tabtitle="Headertext.cs" %} +{% include code-snippet/grid/columns/headertext-using-event/headertext.cs %} +{% endhighlight %} +{% endtabs %} + +![Using event](../../images/columns/Column-headertext-using-event.png) + +## How to refresh header + +The refresh header feature in the Syncfusion ASP.NET MVC Grid allows you to update the header section of the grid whenever changes are made to the grid's columns. This feature is useful when you want to reflect changes in the header immediately, such as modifying the column header text, width, or alignment. + +To use the refresh header feature, you can call the `refreshHeader` method of the Grid component. This method updates the grid header with the latest changes made to the columns. + +The following example demonstrates how to use the `refreshHeader` method to update the grid header: + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/headertext-refresh/razor %} +{% endhighlight %} +{% highlight c# tabtitle="Headertext.cs" %} +{% include code-snippet/grid/columns/headertext-refresh/headertext.cs %} +{% endhighlight %} +{% endtabs %} + +![How to refresh header](../../images/columns/Column-headertext-refresh-header.png) + +>* The `refreshHeader` method updates only the grid header and not the entire grid. +>* If you want to refresh the entire grid, you can use the `refresh` method instead. + +## How to get header element + +To get the header element in a Syncfusion Grid, you can use one of the following methods: + +1. `getHeaderContent`: This method returns the header div element of the Grid. You can use this method to access the entire header content of the Grid. + + ```ts + var grid = document.getElementById("Grid").ej2_instances[0] + const headerTableElement=grid.getHeaderContent(); + ``` +2. `getHeaderTable`: This method returns the header table element of the Grid. You can use this method to access only the header table of the Grid. + + ```ts + var grid = document.getElementById("Grid").ej2_instances[0] + const headerTableElement = grid.getHeaderTable(); + ``` + +3. `getColumnHeaderByUid`: This method returns the column header element by its unique identifier. + + ```ts + var grid = document.getElementById("Grid").ej2_instances[0] + const columnHeaderElement = grid.getColumnHeaderByUid("e-grid2"); + ``` + +4. `getColumnHeaderByIndex`: This method returns the column header element by its index. + + ```ts + var grid = document.getElementById("Grid").ej2_instances[0] + const columnHeaderElement = grid.getColumnHeaderByIndex(0); + ``` +5. `getColumnHeaderByField`: This method returns the column header element by its field name. + + ```ts + var grid = document.getElementById("Grid").ej2_instances[0] + const columnHeaderElement = grid.getColumnHeaderByField("OrderID"); + ``` + +>* The UID is automatically generated by the Grid component and may change whenever the grid is refreshed or updated. \ No newline at end of file diff --git a/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/columns/column-menu.md b/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/columns/column-menu.md index 9b0e0d022d..278e2ab2a6 100644 --- a/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/columns/column-menu.md +++ b/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/columns/column-menu.md @@ -8,177 +8,134 @@ publishingplatform: ##Platform_Name## documentation: ug --- -# Column Menu +# Column menu in ASP.NET MVC Grid component -The column menu has options to integrate features like sorting, grouping, filtering, column chooser, and autofit. It will show a menu with the integrated feature when users click on multiple icon of the column. To enable column menu, you need to define the [`ShowColumnMenu`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ShowColumnMenu) property as true. +The column menu in the Syncfusion ASP.NET MVC Grid component provides options to enable features such as sorting, grouping, filtering, column chooser, and autofit. When users click on the column header's menu icon, a menu will be displayed with these integrated features. To enable the column menu, you need to set the [ShowColumnMenu](https://help.syncfusion.com/cr/aspnetmvc-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_ShowColumnMenu) property to **true** in the Grid configuration. -The default items are displayed in following table. +The default column menu items are displayed in following table. -| Item | Description | -|-----|-----| -| `SortAscending` | Sort the current column in ascending order. | -| `SortDescending` | Sort the current column in descending order. | -| `Group` | Group the current column. | -| `Ungroup` | Ungroup the current column. | -| `AutoFit` | Auto fit the current column. | -| `AutoFitAll` | Auto fit all columns. | -| `ColumnChooser` | Choose the column visibility. | -| `Filter` | Show the filter option as given in `FilterSettings.Type` | - -{% if page.publishingplatform == "aspnet-core" %} +| Item | Description | +| ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------- | +| **SortAscending** | Sort the current column in ascending order. | +| **SortDescending** | Sort the current column in descending order. | +| **Group** | Group the current column. | +| **Ungroup** | Ungroup the current column. | +| **AutoFit** | Autofit the current column. | +| **AutoFitAll** | Autofit all columns. | +| **ColumnChooser** | Choose the column visibility. | +| **Filter** | Show the filter option as given in [FilterSettings.Type](https://help.syncfusion.com/cr/aspnetmvc-js2/Syncfusion.EJ2.Grids.GridFilterSettings.html#Syncfusion_EJ2_Grids_GridFilterSettings_Type) | {% tabs %} {% highlight cshtml tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/columnmenu/tagHelper %} -{% endhighlight %} -{% highlight c# tabtitle="Columnmenu.cs" %} -{% include code-snippet/grid/columns/columnmenu/columnmenu.cs %} -{% endhighlight %} -{% endtabs %} - -{% elsif page.publishingplatform == "aspnet-mvc" %} - -{% tabs %} -{% highlight razor tabtitle="CSHTML" %} {% include code-snippet/grid/columns/columnmenu/razor %} {% endhighlight %} {% highlight c# tabtitle="Columnmenu.cs" %} {% include code-snippet/grid/columns/columnmenu/columnmenu.cs %} {% endhighlight %} {% endtabs %} -{% endif %} - +![Column menu](../../images/column-menu/Column-menu.png) -N> You can disable column menu for a particular column by defining the [`ShowColumnMenu`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html#Syncfusion_EJ2_Grids_GridColumn_ShowColumnMenu) property of [`Columns`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html) as false. -
You can customize the default items by defining the [`ColumnMenuItems`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ColumnMenuItems) with required items. +> You can disable column menu for a particular column by defining the `Columns.ShowColumnMenu` as **false**. -## Column menu Events +> You can customize the default items by defining the [ColumnMenuItems](https://help.syncfusion.com/cr/aspnetmvc-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_ColumnMenuItems) with required items. -During the resizing action, the grid component triggers the below two events. +## Add custom column menu item -1. The [`ColumnMenuOpen`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ColumnMenuOpen) event triggers before the column menu opens. -2. The [`ColumnMenuClick`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ColumnMenuClick) event triggers when the user clicks the column menu of the grid. +The custom column menu item feature allows you to add additional menu items to the column menu in the Syncfusion Grid. These custom menu items can be defined using the [ColumnMenuItems](https://help.syncfusion.com/cr/aspnetmvc-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_ColumnMenuItems) property, which accepts a collection of `columnMenuItemModel` objects. You can define the actions for these custom items in the [ColumnMenuClick](https://help.syncfusion.com/cr/aspnetmvc-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_ColumnMenuClick) event. -{% if page.publishingplatform == "aspnet-core" %} +Consider the following example, which demonstrates how to add a custom column menu item to clear the sorting of the Grid: {% tabs %} {% highlight cshtml tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/columnmenuevents/tagHelper %} -{% endhighlight %} -{% highlight c# tabtitle="Columnmenuevents.cs" %} -{% include code-snippet/grid/columns/columnmenuevents/columnmenuevents.cs %} -{% endhighlight %} -{% endtabs %} - -{% elsif page.publishingplatform == "aspnet-mvc" %} - -{% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/columnmenuevents/razor %} +{% include code-snippet/grid/columns/customcolumnmenu/razor %} {% endhighlight %} -{% highlight c# tabtitle="Columnmenuevents.cs" %} -{% include code-snippet/grid/columns/columnmenuevents/columnmenuevents.cs %} +{% highlight c# tabtitle="Columnmenu.cs" %} +{% include code-snippet/grid/columns/customcolumnmenu/columnmenu.cs %} {% endhighlight %} {% endtabs %} -{% endif %} - +![custom menu](../../images/column-menu/Column-menu-custom.gif) -## Custom column menu item - -Custom column menu items can be added by defining the [`ColumnMenuItems`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ColumnMenuItems) as collection of the ColumnMenuItemModel. +## Customize menu items for particular columns -Actions for this customized items can be defined in the [`ColumnMenuClick`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ColumnMenuClick) event. +Sometimes, you have a scenario that to hide an item from column menu for particular columns. In that case, you need to define the `columnMenuOpenEventArgs.hide` as **true** in the [ColumnMenuOpen](https://help.syncfusion.com/cr/aspnetmvc-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_ColumnMenuOpen) event. -{% if page.publishingplatform == "aspnet-core" %} +The following sample, **Filter** item was hidden in column menu when opens for the **OrderID** column. {% tabs %} {% highlight cshtml tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/customcolumnmenu/tagHelper %} -{% endhighlight %} -{% highlight c# tabtitle="Customcolumnmenu.cs" %} -{% include code-snippet/grid/columns/customcolumnmenu/customcolumnmenu.cs %} -{% endhighlight %} -{% endtabs %} - -{% elsif page.publishingplatform == "aspnet-mvc" %} - -{% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/customcolumnmenu/razor %} +{% include code-snippet/grid/columns/customizecolumnmenu/razor %} {% endhighlight %} -{% highlight c# tabtitle="Customcolumnmenu.cs" %} -{% include code-snippet/grid/columns/customcolumnmenu/customcolumnmenu.cs %} +{% highlight c# tabtitle="Columnmenu.cs" %} +{% include code-snippet/grid/columns/customizecolumnmenu/columnmenu.cs %} {% endhighlight %} {% endtabs %} -{% endif %} +![Customize menu items for particular columns](../../images/column-menu/Column-menu-particular.png) +## Render nested column menu -## Customize menu items for particular columns +The nested column menu feature provides an extended menu option in the grid column headers, allows you to access additional actions and options related to the columns. -Sometimes, you have a scenario that to hide an item from column menu for particular columns. In that case, you need to define the **hide** as true in the arguments of [`ColumnMenuOpen`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ColumnMenuOpen) event. +To enable the nested column menu feature, you need to define the [ColumnMenuItems](https://help.syncfusion.com/cr/aspnetmvc-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_ColumnMenuItems) property in your component. The `ColumnMenuItems` property is an array that contains the items for the column menu. Each item can be a string representing a built-in menu item or an object defining a custom menu item. -The following sample, **Filter** item was hidden in column menu when opens for the **OrderID** column. - -{% if page.publishingplatform == "aspnet-core" %} +Here is an example of how to configure the `ColumnMenuItems` property to include a nested menu: {% tabs %} {% highlight cshtml tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/customizecolumnmenu/tagHelper %} +{% include code-snippet/grid/columns/columnmenu-stacked/razor %} {% endhighlight %} -{% highlight c# tabtitle="Customizecolumnmenu.cs" %} -{% include code-snippet/grid/columns/customizecolumnmenu/customizecolumnmenu.cs %} +{% highlight c# tabtitle="Columnmenu.cs" %} +{% include code-snippet/grid/columns/columnmenu-stacked/columnmenu.cs %} {% endhighlight %} {% endtabs %} -{% elsif page.publishingplatform == "aspnet-mvc" %} - -{% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/customizecolumnmenu/razor %} -{% endhighlight %} -{% highlight c# tabtitle="Customizecolumnmenu.cs" %} -{% include code-snippet/grid/columns/customizecolumnmenu/customizecolumnmenu.cs %} -{% endhighlight %} -{% endtabs %} -{% endif %} +![Render nested column menu](../../images/column-menu/Column-menu-stacked.png) +## Customize the icon of column menu +To customize the column menu icon, you need to override the default grid class **.e-icons.e-columnmenu** with a custom CSS property called **content**. By specifying a Unicode character or an icon font's CSS class, you can change the icon displayed in the column menu. -## Customize the icon of column menu +To customize the column menu icon, follow the below step: -You can customize the column menu icon by overriding the default grid class **.e-icons.e-columnmenu** with a custom property **content** as mentioned below, +1.Add the necessary CSS code to override the default grid class: ```css -.e-grid .e-columnheader .e-icons.e-columnmenu::before { - content: "\e941"; -} + .e-grid .e-columnheader .e-icons.e-columnmenu::before { + content: "\e799"; + } ``` -In the below sample, grid is rendered with a customized column menu icon. +Here is an example that demonstrates how to customize the column menu icon in the Syncfusion Grid: -{% if page.publishingplatform == "aspnet-core" %} {% tabs %} {% highlight cshtml tabtitle="CSHTML" %} -{% include code-snippet/grid/how-to/custom-column-menu-icon/tagHelper %} +{% include code-snippet/grid/columns/custom-column-menu-icon/razor %} {% endhighlight %} -{% highlight c# tabtitle="Column-icon.cs" %} -{% include code-snippet/grid/how-to/custom-column-menu-icon/column-icon.cs %} +{% highlight c# tabtitle="Columnmenu.cs" %} +{% include code-snippet/grid/columns/custom-column-menu-icon/columnmenu.cs %} {% endhighlight %} {% endtabs %} -{% elsif page.publishingplatform == "aspnet-mvc" %} +![Customize the icon of column menu](../../images/column-menu/column-menu-icon.png) + +## Column menu events + +The column menu in Syncfusion ASP.NET MVC Grid provides a set of events that allow customization of behavior and performing actions when the column menu is opened or clicked. The below events are helpful for adding additional functionality or implementing specific actions based on user interactions with the column menu. + +1.The [ColumnMenuOpen](https://help.syncfusion.com/cr/aspnetmvc-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_ColumnMenuOpen) event triggers before the column menu opens. + +2.The [ColumnMenuClick](https://help.syncfusion.com/cr/aspnetmvc-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_ColumnMenuClick) event triggers when the user clicks the column menu of the grid. {% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/grid/how-to/custom-column-menu-icon/razor %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/columnmenuevents/razor %} {% endhighlight %} -{% highlight c# tabtitle="Column-icon.cs" %} -{% include code-snippet/grid/how-to/custom-column-menu-icon/column-icon.cs %} +{% highlight c# tabtitle="Columnmenu.cs" %} +{% include code-snippet/grid/columns/columnmenuevents/columnmenu.cs %} {% endhighlight %} {% endtabs %} -{% endif %} +![Column menu events](../../images/column-menu/column-menu-events.gif) diff --git a/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/columns/column-rendering.md b/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/columns/column-rendering.md new file mode 100644 index 0000000000..27fd1f60ba --- /dev/null +++ b/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/columns/column-rendering.md @@ -0,0 +1,218 @@ +--- +layout: post +title: Column Rendering in ##Platform_Name## Grid Component +description: Learn here all about Column Rendering in Syncfusion ##Platform_Name## Grid component of Syncfusion Essential JS 2 and more. +platform: ej2-asp-core-mvc +control: Column Rendering +publishingplatform: ##Platform_Name## +documentation: ug +--- + +# Column rendering in ASP.NET MVC Grid component + +In Syncfusion ASP.NET MVC Grid, column rendering provides you with the ability to finely control how data is presented. This allows you to manually define columns, automatically generate them, and dynamically customize data presentation. With column rendering, you can ensure that your data is displayed exactly as needed, offering a wide range of possibilities for organizing and showcasing information within the grid. + +The column definitions are used as the DataSource schema in the grid. The grid operations such as sorting, filtering and grouping etc. are performed based on column definitions. The `Field` property of grid column is necessary to map the datasource values in the grid columns. + +> 1. If the column `Field` is not specified in the [DataSource](https://help.syncfusion.com/cr/aspnetmvc-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_DataSource), column values will be empty. +> 2. If the `Field` name contains **dot** operator, it is considered as complex binding. +> 3. It is must to define the `Field` property for a Template column, to perform CRUD or data Operations such as filtering, searching etc. + +## Define columns manually + +To define columns manually in grid, you can use the `Column` element to define the columns and represent each column with its respective properties such as `Field`, `HeaderText`, `Type`, and [Width](https://help.syncfusion.com/cr/aspnetmvc-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_Width) set accordingly. This allows you to customize the column's behavior and appearance based on the requirements. + +Here's an example code snippet that demonstrates how to define columns manually in the Syncfusion ASP.NET MVC Grid: + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/column-rendering/razor %} +{% endhighlight %} +{% highlight c# tabtitle="Column-rendering.cs" %} +{% include code-snippet/grid/columns/column-rendering/column-rendering.cs %} +{% endhighlight %} +{% endtabs %} + +![Define columns](../../images/column-rendering/column-render.png) + +## Auto generated columns + +The Grid automatically generates columns when the `Columns` declaration is empty or undefined while initializing the grid. All the columns in the **dataSource** are bound as grid columns. + +You can use the following code snippet to enable auto-generated columns in the Syncfusion Grid: + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/auto/razor %} +{% endhighlight %} +{% highlight c# tabtitle="Auto.cs" %} +{% include code-snippet/grid/columns/auto/auto.cs %} +{% endhighlight %} +{% endtabs %} + +>* When the columns are auto-generated, the column `Type` is determined from the first record of the [DataSource](https://help.syncfusion.com/cr/aspnetmvc-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_DataSource). +>* If you have a large dataset, auto-generating columns can result in performance issues. In this case, it is recommended to specify the columns manually in the columns property during initialization or else use column virtualization feature by setting [EnableColumnVirtualization](https://help.syncfusion.com/cr/aspnetmvc-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_EnableColumnVirtualization) property value as **true**. + +### Set isPrimaryKey for auto generated columns when editing is enabled + +When editing is enabled in the grid, you may need to set a primary key for auto-generated columns to uniquely identify each row for operations such as updating or deleting data. This can be achieved using the `isPrimaryKey` property of the column object by using the [DataBound](https://help.syncfusion.com/cr/aspnetmvc-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_DataBound) event. + +By setting `IsPrimaryKey` to **true** for an auto-generated column in the Syncfusion Grid, you can specify it as the primary key column, which uniquely identifies each row when editing is enabled. + +Here is an example code snippet that shows how to set a primary key for an auto-generated column when editing is enabled: + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/auto-primary/razor %} +{% endhighlight %} +{% highlight c# tabtitle="Primary.cs" %} +{% include code-snippet/grid/columns/auto-primary/primary.cs %} +{% endhighlight %} +{% endtabs %} + +If the column `Field` name is known, the `getColumnByField` method can be used to retrieve the column object. Then, the `IsPrimaryKey` property can be set to **true** for that column, as demonstrated in the code snippet below: + +```typescript +onDataBound: function() { + let grid = document.getElementById('Grid').ej2_instances[0]; + let column= grid.getColumnByField('OrderID'); + column.isPrimaryKey = true; + } +``` + +### Set column options to auto generated columns + +To configure column options such as `Type`, `Format` and [Width](https://help.syncfusion.com/cr/aspnetmvc-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_Width) for auto-generated columns in Syncfusion Grid, you can use the [DataBound](https://help.syncfusion.com/cr/aspnetmvc-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_DataBound) event of the Grid component. This event is triggered after the data has been bound to the Grid. By handling this event, you can specify the desired column options for the auto-generated columns. + +Here's an example of how you can set column options for auto-generated columns using the `dataBound` event: + +In the below example, `width` is set for **OrderID** column, **date** `type` is set for **OrderDate** column and `format` is set for **Freight** and **OrderDate** column. + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/autocolumnformat/razor %} +{% endhighlight %} +{% highlight c# tabtitle="Autocolumnformat.cs" %} +{% include code-snippet/grid/columns/autocolumnformat/autocolumnformat.cs %} +{% endhighlight %} +{% endtabs %} + +## Dynamic column generation + +The Syncfusion Grid component allows you to dynamically generate columns at runtime, based on the data provided. This feature is useful when you need to display data with varying columns based on user requirements or dynamic data sources. + +### Using valueAccessor property + +Dynamic column generation using value accessor allows you to access and manipulate the display data values in a grid column. By using the `valueAccessor` property of a grid column, you can customize the display value of the column based on the data. + +To use `valueAccessor` property, define the column with the property and provide a function that will return the formatted value. The function receives two arguments: +* **field**: represents the data field of the column. +* **data**: represents the data record for the corresponding row. + +In the provided code, the **currencyFormatter** function takes the Freight value of the data object, appends the Euro symbol to it, and returns the formatted string. The **concatenateFields** function concatenates the ShipCity and ShipRegion values of the data object and returns the combined string. + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/column-render-valueaccessor/razor %} +{% endhighlight %} +{% highlight c# tabtitle="Valueaccessor.cs" %} +{% include code-snippet/grid/columns/column-render-valueaccessor/valueaccessor.cs %} +{% endhighlight %} +{% endtabs %} + +![Using valueAccessor property](../../images/column-rendering/column-render-valueaccessor.png) + +> The `ValueAccessor` function can have performance implications if it is used to access a large number of data records or to perform complex data manipulations. To avoid performance issues, you can enable the virtualization feature while using the `ValueAccessor` property. This ensures that only the visible rows are rendered, resulting in faster rendering times. + +### Display array type columns + +The Grid component allows you to easily bind an array of objects to a column using the `ValueAccessor` property. This property allows customization of how the data is displayed in the column. + +For example, consider a column named **Name** that contains an array of two objects, **FirstName** and **LastName**. The `ValueAccessor` property can be used to join these two objects and bind them to the column. + +This will display the concatenated value of **FirstName** and **LastName** in the **Full Name** column of the grid. Here's an example of how this can be achieved: + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/column-render-array/razor %} +{% endhighlight %} +{% highlight c# tabtitle="Arraytypecolumns.cs" %} +{% include code-snippet/grid/columns/column-render-array/arraytypecolumns.cs %} +{% endhighlight %} +{% endtabs %} + +![Display array type columns](../../images/column-rendering/column-render-array.png) + +### Expression column + +You can achieve an expression column in the Grid by using the `ValueAccessor` property. The `ValueAccessor` property allows you to define a function that calculates the value for the expression column based on the values of other columns. + +In this example, we have a grid with columns **Food Name**, **Protein**, **Fat**, and **Carbohydrate**. We want to add an expression column called **Calories Intake** that calculates the total calories for each row based on the values of **Protein**, **Fat**, and **Carbohydrate** columns. + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/column-render-expression/razor %} +{% endhighlight %} +{% highlight c# tabtitle="Expressioncolumn.cs" %} +{% include code-snippet/grid/columns/column-render-expression/expressioncolumn.cs %} +{% endhighlight %} +{% endtabs %} + +![Expression column](../../images/column-rendering/column-render-expression%20.png) + +### Display serial number + +To display serial number in the grid for every rows, you can use the [RowDataBound](https://help.syncfusion.com/cr/aspnetmvc-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_RowDataBound) event. The `RowDataBound` event is triggered for each row in the grid when the data is bound to the grid. + +Within the event handler, the [pagesize](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridPageSettings.html#Syncfusion_EJ2_Grids_GridPageSettings_PageSize) and [currentPage](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridPageSettings.html#Syncfusion_EJ2_Grids_GridPageSettings_CurrentPage) index can be obtained from the grid's [PageSettings](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridPageSettings.html) property. Using these values, the serial number can be calculated based on the page size, current page, and row index. Finally, the calculated serial number can be set as the innerHTML of the corresponding row cell. + +Here is an example code snippet that demonstrates how to display serial numbers in a Syncfusion Grid using `rowDataBound` event: + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/column-render-serial/razor %} +{% endhighlight %} +{% highlight c# tabtitle="Serialnumber.cs" %} +{% include code-snippet/grid/columns/column-render-serial/serialnumber.cs %} +{% endhighlight %} +{% endtabs %} + +![Display serial number](../../images/column-rendering/column-render-serial.png) + +## Complex data binding + +The Syncfusion Grid component allows you to achieve complex data binding by using the dot (.) operator in the `Column.Field`. This feature is particularly useful when dealing with nested or complex data structures. + +### Using local data + +To enable complex data binding in the Grid component using local data, use the dot (.) operator in the `Field` property of the column. Here is an example of how to achieve complex data binding using local data: + +In the below example, we have bound the nested **Employee** object's **FirstName** and **LastName** properties using the dot (.) operator. + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/complexbinding/razor %} +{% endhighlight %} +{% highlight c# tabtitle="Complexbinding.cs" %} +{% include code-snippet/grid/columns/complexbinding/complexbinding.cs %} +{% endhighlight %} +{% endtabs %} + +![Using local data](../../images/column-rendering/local-data.png) + +### Using remote data + +To enable complex data binding in the Grid component using remote data, add the `expand` query to the [Query](https://help.syncfusion.com/cr/aspnetmvc-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_Query) property of the Grid, to eager load the complex data. Here is an example of how to achieve complex data binding using remote data: + +In the below example, we have used the `expand` query to load the nested Employee object's **City** property using the dot (.) operator. + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/column-render-remote/razor %} +{% endhighlight %} +{% highlight c# tabtitle="Remotedata.cs" %} +{% include code-snippet/grid/columns/column-render-remote/remotedata.cs %} +{% endhighlight %} +{% endtabs %} + +![Using remote data](../../images/column-rendering/column-render-remote.png) diff --git a/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/columns/column-reorder.md b/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/columns/column-reorder.md index 8f418887fd..9d73d6a878 100644 --- a/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/columns/column-reorder.md +++ b/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/columns/column-reorder.md @@ -8,125 +8,132 @@ publishingplatform: ##Platform_Name## documentation: ug --- -# Reorder +# Column reorder in ASP.NET MVC Grid component + +The Syncfusion ASP.NET MVC Grid component allows to reorder columns by drag and drop of a particular column header from one index to another index within the grid. -Reordering can be done by drag and drop of a particular column header from one index to another index within the grid. To enable reordering, set the [`AllowReordering`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_AllowReordering) to true. +To reorder the columns, set the [AllowReordering](https://help.syncfusion.com/cr/aspnetmvc-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_AllowReordering) property to **true** in the grid. -{% if page.publishingplatform == "aspnet-core" %} +Here's an example for column reordering in your Grid component: {% tabs %} {% highlight cshtml tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/reorder/tagHelper %} +{% include code-snippet/grid/columns/reorder/razor %} {% endhighlight %} {% highlight c# tabtitle="Reorder.cs" %} {% include code-snippet/grid/columns/reorder/reorder.cs %} {% endhighlight %} {% endtabs %} -{% elsif page.publishingplatform == "aspnet-mvc" %} +![Column reorder](../../images/column-reorder/column-reorder.gif) + +>* You can customize the appearance of the column headers during drag and drop by using the [ColumnDrag](https://help.syncfusion.com/cr/aspnetmvc-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ColumnDrag) and [ColumnDrop](https://help.syncfusion.com/cr/aspnetmvc-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ColumnDrop) events. +>* When columns are reordered, the position of the corresponding column data will also be changed. As a result, you should ensure that any additional code or logic that relies on the order of the column data is updated accordingly. + +## Prevent reordering for particular column + +By default, all columns in the Syncfusion ASP.NET MVC Grid can be reordered by dragging and dropping their headers to another location within the grid. However, there may be certain columns that you do not want to be reordered. In such cases, you can set the `AllowReordering` property of that particular column to **false**. Here is an example that demonstrates how to prevent reordering for a specific column: + +In this example, the **ShipName** column is prevented from being reordered by setting the `AllowReordering` property to **false**. {% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/reorder/razor %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/reorder-prevent/razor %} {% endhighlight %} {% highlight c# tabtitle="Reorder.cs" %} -{% include code-snippet/grid/columns/reorder/reorder.cs %} +{% include code-snippet/grid/columns/reorder-prevent/reorder.cs %} {% endhighlight %} {% endtabs %} -{% endif %} +![Prevent reordering for particular column](../../images/column-reorder/column-reorder-prevent.gif) +## Reorder columns externally -N> You can disable reordering a particular column by setting the [`AllowReordering`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html#Syncfusion_EJ2_Grids_GridColumn_AllowReordering) property of [`Columns`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html) to false. +The Syncfusion Grid ASP.NET MVC allows you to reorder columns externally, which means that using methods you can programmatically move columns around within the grid, based on their index or target index, or by using their field name. -## Reorder single column +> When reordering columns externally, you must set the [AllowReordering](https://help.syncfusion.com/cr/aspnetmvc-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_AllowReordering) property of the grid to **true**. -Grid have option to reorder Columns either by Interaction or by using the **reorderColumns** method. In the below sample, **Name** column is reordered to last column position by using the method. +### Reorder column based on index -{% if page.publishingplatform == "aspnet-core" %} +You can use the `reorderColumnByIndex` method to reorder columns based on their current index. This method takes two arguments: -{% tabs %} -{% highlight cshtml tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/reordercols/tagHelper %} -{% endhighlight %} -{% highlight c# tabtitle="Reordercols.cs" %} -{% include code-snippet/grid/columns/reordercols/reordercols.cs %} -{% endhighlight %} -{% endtabs %} +* **fromIndex** : Current index of the column to be reordered +* **toIndex** : New index of the column after the reordering -{% elsif page.publishingplatform == "aspnet-mvc" %} +Here is an example of how to use the `reorderColumnByIndex` method: + +In this example, we are moving the column at index **1** to index **3**. {% tabs %} -{% highlight razor tabtitle="CSHTML" %} +{% highlight cshtml tabtitle="CSHTML" %} {% include code-snippet/grid/columns/reordercols/razor %} {% endhighlight %} -{% highlight c# tabtitle="Reordercols.cs" %} -{% include code-snippet/grid/columns/reordercols/reordercols.cs %} +{% highlight c# tabtitle="Reorder.cs" %} +{% include code-snippet/grid/columns/reordercols/reorder.cs %} {% endhighlight %} {% endtabs %} -{% endif %} - +![Reorder column based on index](../../images/column-reorder/column-reorder-index.gif) -## Reorder multiple columns +### Reorder column based on target index -User can reorder a single column at a time by Interaction. Sometimes we need to have reorder multiple columns at the same time, It can be achieved through programmatically by using **reorderColumns** method. +You can also use the `reorderColumnByTargetIndex` method to reorder single column or multiple columns based on the target index. This method takes two arguments: -In the below sample, **Ship City** and **Ship Region** column is reordered to last column position. +* **fieldName**: Field name of the column to be reordered +* **toIndex**: New index of the column after the reordering -{% if page.publishingplatform == "aspnet-core" %} +Here is an example of how to use the `reorderColumnByTargetIndex` method to reorder single column and multiple columns based on target index: {% tabs %} {% highlight cshtml tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/reordercolumns/tagHelper %} +{% include code-snippet/grid/columns/reordertargetcolumns/razor %} {% endhighlight %} -{% highlight c# tabtitle="Reordercols.cs" %} -{% include code-snippet/grid/columns/reordercolumns/reordercols.cs %} +{% highlight c# tabtitle="Reorder.cs" %} +{% include code-snippet/grid/columns/reordertargetcolumns/reorder.cs %} {% endhighlight %} {% endtabs %} -{% elsif page.publishingplatform == "aspnet-mvc" %} +![Reorder column based on target index](../../images/column-reorder/column-reorder-target.gif) + +### Reorder column based on field names + +The `reorderColumns` method of the Grid allows you to reorder single column or list of columns based on their field names. This method takes two arguments: + +* **fromFName**: The field name of the column you want to move. +* **toFName**: The field name of the column you want to move the column to. + +Here is an example of how to use the `reorderColumns` method to reorder single column and multiple columns based on field names: {% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/reordercolumns/razor %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/reorder-field/razor %} {% endhighlight %} -{% highlight c# tabtitle="Reordercols.cs" %} -{% include code-snippet/grid/columns/reordercolumns/reordercols.cs %} +{% highlight c# tabtitle="Reorder.cs" %} +{% include code-snippet/grid/columns/reorder-field/reorder.cs %} {% endhighlight %} -{% endtabs %} -{% endif %} - +{% endtabs %} +![Reorder column based on field names](../../images/column-reorder/column-reorder-field.gif) ## Reorder events -During the reorder action, the grid component triggers the below three events. +When reordering columns in the Syncfusion ASP.NET MVC Grid component, you may want to take some specific action in response to the drag and drop events. To handle these events, you can define event handlers for the following events: -1. The [`ColumnDragStart`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ColumnDragStart) event triggers when column header element drag (move) starts. -2. The [`ColumnDrag`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ColumnDrag) event triggers when column header element is dragged (moved) continuously. -3. The [`ColumnDrop`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ColumnDrop) event triggers when a column header element is dropped on the target column. +1.The [ColumnDragStart](https://help.syncfusion.com/cr/aspnetmvc-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ColumnDragStart) event triggers when column header element drag (move) starts. -{% if page.publishingplatform == "aspnet-core" %} +2.The [ColumnDrag](https://help.syncfusion.com/cr/aspnetmvc-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ColumnDrag) event triggers when column header element is dragged (moved) continuously. -{% tabs %} -{% highlight cshtml tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/reorderevents/tagHelper %} -{% endhighlight %} -{% highlight c# tabtitle="Reorderevents.cs" %} -{% include code-snippet/grid/columns/reorderevents/reorderevents.cs %} -{% endhighlight %} -{% endtabs %} +3.The [ColumnDrop](https://help.syncfusion.com/cr/aspnetmvc-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ColumnDrop) event triggers when a column header element is dropped on the target column. -{% elsif page.publishingplatform == "aspnet-mvc" %} +In the following example, we have implemented the `ColumnDragStart`, `ColumnDrag`, and `ColumnDrop` events in the Syncfusion Grid component. {% tabs %} -{% highlight razor tabtitle="CSHTML" %} +{% highlight cshtml tabtitle="CSHTML" %} {% include code-snippet/grid/columns/reorderevents/razor %} {% endhighlight %} -{% highlight c# tabtitle="Reorderevents.cs" %} -{% include code-snippet/grid/columns/reorderevents/reorderevents.cs %} +{% highlight c# tabtitle="Reorder.cs" %} +{% include code-snippet/grid/columns/reorderevents/reorder.cs %} {% endhighlight %} {% endtabs %} -{% endif %} +![Reorder events](../../images/column-reorder/column-reorder-events.gif) diff --git a/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/columns/column-resizing.md b/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/columns/column-resizing.md index 9150effc9c..8150de5da4 100644 --- a/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/columns/column-resizing.md +++ b/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/columns/column-resizing.md @@ -8,153 +8,167 @@ publishingplatform: ##Platform_Name## documentation: ug --- -# Column Resizing in ASP.Net MVC Grid component +# Column resizing in ASP.NET MVC Grid component -Column width can be resized by clicking and dragging the right edge of the column header. While dragging, the width of the respective column will be resized immediately. Each column can be auto resized by double-clicking the right edge of the column header to fit the width of that column based on the widest cell content. To enable column resize, set the [`AllowResizing`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_AllowResizing) property to true. +Grid component provides an intuitive user interface for resizing columns to fit their content. This feature allows users to easily adjust the width of the columns to improve readability and aesthetics of the data presented. To enable column resizing, set the [AllowResizing](https://help.syncfusion.com/cr/aspnetmvc-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_AllowResizing) property of the grid to **true**. -{% if page.publishingplatform == "aspnet-core" %} +Once column resizing is enabled, columns width can be resized by clicking and dragging at the right edge of the column header. While dragging the column, the width of the respective column will be resized immediately. {% tabs %} {% highlight cshtml tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/resize/tagHelper %} -{% endhighlight %} -{% highlight c# tabtitle="Resize.cs" %} -{% include code-snippet/grid/columns/resize/resize.cs %} -{% endhighlight %} -{% endtabs %} - -{% elsif page.publishingplatform == "aspnet-mvc" %} - -{% tabs %} -{% highlight razor tabtitle="CSHTML" %} {% include code-snippet/grid/columns/resize/razor %} {% endhighlight %} {% highlight c# tabtitle="Resize.cs" %} {% include code-snippet/grid/columns/resize/resize.cs %} {% endhighlight %} {% endtabs %} -{% endif %} - - - -N> You can disable resizing for a particular column by setting the [`AllowResizing`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html#Syncfusion_EJ2_Grids_GridColumn_AllowResizing) property of [`Columns`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html) to false. -
In RTL mode, you can click and drag the left edge of the header cell to resize the column. - -## Column resizing using method - -To resize a column, set width to that particular column and then refresh the grid header by using the **refreshHeader** method. Refer the below code, -```typescript +![Column resizing](../../images/column-resize/column-resize.gif) -var grid = document.getElementById('Grid').ej2_instances[0]; //Grid Instance +>* You can disable Resizing for a particular column, by specifying `Columns.AllowResizing` to **false**. +>* In RTL mode, you can click and drag the left edge of header cell to resize the column. +>* The `Width` property of the column can be set initially to define the default width of the column. However, when column resizing is enabled, you can override the default width by manually resizing the columns. -var columns = grid.columns; +## Restrict the resizing based on minimum and maximum width -columns[0].width = 150; +The Grid component allows you to restrict the column width resizing between a minimum and maximum width. This can be useful when you want to ensure that your grid's columns stay within a certain range of sizes. -grid.refreshHeader(); +To enable this feature, you can define the `Columns.MinWidth` and `Columns.MaxWidth` properties of the columns directive for the respective column. -``` - -## Min and max width - -Column resize can be restricted between minimum and maximum width by defining the [`MinWidth`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html#Syncfusion_EJ2_Grids_GridColumn_MinWidth) and [`MaxWidth`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html#Syncfusion_EJ2_Grids_GridColumn_MaxWidth) properties of [`Columns`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html). - -In the following sample, minimum and maximum width are defined for **OrderID**, **Ship Name**, and **Ship Country** columns. - -{% if page.publishingplatform == "aspnet-core" %} +In the below code, **OrderID**, **Ship Name** and **Ship Country** columns are defined with minimum and maximum width. The **OrderID** column is set to have a minimum width of 100 pixels and a maximum width of 250 pixels. Similarly, the **CustomerID** column is set to have a minimum width of 150 pixels and a maximum width of 300 pixels. The **ShipCountry** column is set to have a minimum width of 120 pixels and a maximum width of 260 pixels. {% tabs %} {% highlight cshtml tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/min/tagHelper %} +{% include code-snippet/grid/columns/resize-max/razor %} {% endhighlight %} -{% highlight c# tabtitle="Min.cs" %} -{% include code-snippet/grid/columns/min/min.cs %} +{% highlight c# tabtitle="Resize.cs" %} +{% include code-snippet/grid/columns/resize-max/resize.cs %} {% endhighlight %} {% endtabs %} -{% elsif page.publishingplatform == "aspnet-mvc" %} +![Restrict the resizing based on minimum and maximum width](../../images/column-resize/Colum-resize-max.gif) + +>* The `Columns.MinWidth` and `Columns.MaxWidth` properties will be considered only when the user resizes the column. When resizing the window, these properties will not be considered. This is because columns cannot be re-rendered when resizing the window. +>* When setting the `MinWidth` and `MaxWidth` properties, ensure that the values are appropriate for your data and layout requirements. +>* The specified `MinWidth` and `MaxWidth` values take precedence over any user-initiated resizing attempts that fall outside the defined range. + +## Prevent resizing for particular column + +The Grid component provides the ability to prevent resizing for a particular column. This can be useful if you want to maintain a consistent column width or prevent users from changing the width of a column. + +You can disable resizing for a particular column by setting the `AllowResizing` property of the column to **false**. The following example demonstrates, how to disabled resize for **Customer ID** column. {% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/min/razor %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/resize-prevent/razor %} {% endhighlight %} -{% highlight c# tabtitle="Min.cs" %} -{% include code-snippet/grid/columns/min/min.cs %} +{% highlight c# tabtitle="Resize.cs" %} +{% include code-snippet/grid/columns/resize-prevent/resize.cs %} {% endhighlight %} {% endtabs %} -{% endif %} +> You can also prevent resizing by setting `args.cancel` to **true** in the [ResizeStart](https://help.syncfusion.com/cr/aspnetmvc-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ResizeStart) event. -N> The `maxWidth` and `minWidth` properties will be considered only when the user resizes the column. When resizing the window, these properties will not be considered. This is because columns cannot be re-rendered when resizing the window. +## Resizing modes -## Resize stacked column +The Syncfusion Grid component provides a `ResizeSettingsModel` interface for configuring the resizing behavior of grid columns. The interface includes a property named `mode` which is of the type `ResizeMode`. The `ResizeMode` is an enum that determines the available resizing modes for the grid columns. There are two resizing modes available for grid columns in Grid: -Stacked columns can be resized by clicking and dragging the right edge of the stacked column header. While dragging, the width of the respective child columns will be resized at the same time. You can disable resize for any particular stacked column by setting [`AllowResizing`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html#Syncfusion_EJ2_Grids_GridColumn_AllowResizing) as **false** to its columns. +1. `Normal Mode`: This mode does not adjust the columns to fit the remaining space. When the sum of column width is less than the grid's width, empty space will be present to the right of the last column. When the sum of column width is greater than the grid's width, columns will overflow, and a horizontal scrollbar will appear. -In this example, we have disabled resize for Ship City column. +2. `Auto Mode`: This mode automatically resizes the columns to fill the remaining space. When the sum of column width is less than the grid's width, the columns will be automatically expanded to fill the empty space. Conversely, when the sum of column width is greater than the grid's width, the columns will be automatically contracted to fit within the available space. -{% if page.publishingplatform == "aspnet-core" %} +The following example demonstrates how to set the [ResizeSettings.Mode](https://help.syncfusion.com/cr/aspnetmvc-js2/Syncfusion.EJ2.Grids.GridResizeSettings.html#Syncfusion_EJ2_Grids_GridResizeSettings_Mode) property to **Normal** and **Auto** on changing the dropdown value using the [Change](https://help.syncfusion.com/cr/aspnetmvc-js2/Syncfusion.EJ2.DropDowns.DropDownList.html#Syncfusion_EJ2_DropDowns_DropDownList_Change) event of the DropDownList component. {% tabs %} {% highlight cshtml tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/stacked/tagHelper %} +{% include code-snippet/grid/columns/resize-mode/razor %} {% endhighlight %} -{% highlight c# tabtitle="Stacked.cs" %} -{% include code-snippet/grid/columns/stacked/stacked.cs %} +{% highlight c# tabtitle="Resize.cs" %} +{% include code-snippet/grid/columns/resize-mode/resize.cs %} {% endhighlight %} {% endtabs %} -{% elsif page.publishingplatform == "aspnet-mvc" %} +![Resizing modes](../../images/column-resize/Colum-resize-mode.gif) + +## Resize stacked header column + +Grid component allows to resize stacked columns by clicking and dragging the right edge of the stacked column header. During the resizing action, the width of the child columns is resized at the same time. You can disable resize for any particular stacked column by setting [AllowResizing](https://help.syncfusion.com/cr/aspnetmvc-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_AllowResizing) as **false** to its columns. + +In this below code, we have disabled resize for **Ship City** column. {% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/stacked/razor %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/resize-stacked/razor %} {% endhighlight %} -{% highlight c# tabtitle="Stacked.cs" %} -{% include code-snippet/grid/columns/stacked/stacked.cs %} +{% highlight c# tabtitle="Resize.cs" %} +{% include code-snippet/grid/columns/resize-stacked/resize.cs %} {% endhighlight %} {% endtabs %} -{% endif %} +![Reorder events](../../images/column-resize/Colum-resize-stacked.gif) +> When the [AutoFit](https://help.syncfusion.com/cr/aspnetmvc-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_AutoFit) property is set to **true**, the Grid will automatically adjust its column width based on the content inside them. In `normal` resize mode, if the `AutoFit` property is set to **true**, the Grid will maintain any empty space that is left over after resizing the columns. However, in `auto` resize mode, the Grid will ignore any empty space. ## Touch interaction -When the right edge of the header cell is tapped, a floating handler will be visible over the right border of the column. To resize the column, tap and drag the floating handler as needed. You can autoFit a column by using the Column menu of the grid. +Grid component provides support for touch interactions to enable users to interact with the grid using their mobile devices. Users can resize columns in the grid by tapping and dragging the floating handler, and can also use the Column menu to autofit columns. -The following screenshot represents the column resizing in touch device. +**Resizing Columns on Touch Devices** -![Touch interaction](../../images/column-resizing.jpg) +To resize columns on a touch device: -## Resizing events +1.Tap on the right edge of the header cell of the column that you want to resize. -During the resizing action, the grid component triggers the below three events. +2.A floating handler will appear over the right border of the column. + +3.Tap and drag the floating handler to resize the column to the desired width. -1. The [`ResizeStart`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ResizeStart) event triggers when column resize starts. -2. The [`Resizing`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_Resizing) event triggers when column header element is dragged (moved) continuously. -3. The [`ResizeStop`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ResizeStop) event triggers when column resize ends. +The following screenshot represents the column resizing on the touch device. -{% if page.publishingplatform == "aspnet-core" %} +![Touch Interaction](../../images/column-resizing.jpg) + +## Resizing column externally + +Grid provides the ability to resize columns using an external button click. This can be achieved by changing the `Width` property of the column and refreshing the grid using the `refreshColumns` method in the external button click function. + +The following example demonstrates how to resize the columns in a grid. This is done by using the [Change](https://help.syncfusion.com/cr/aspnetmvc-js2/Syncfusion.EJ2.DropDowns.DropDownList.html#Syncfusion_EJ2_DropDowns_DropDownList_Change) event of the DropDownList component by change the `Width` property of the selected column. This is accomplished using the `getColumnByField` on external button click. Then, the `refreshColumns` method is called on the grid component to update the displayed columns based on interaction. {% tabs %} {% highlight cshtml tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/resizeevents/tagHelper %} +{% include code-snippet/grid/columns/resize-external/razor %} {% endhighlight %} -{% highlight c# tabtitle="Resizeevents.cs" %} -{% include code-snippet/grid/columns/resizeevents/resizeevents.cs %} +{% highlight c# tabtitle="Resize.cs" %} +{% include code-snippet/grid/columns/resize-external/resize.cs %} {% endhighlight %} {% endtabs %} -{% elsif page.publishingplatform == "aspnet-mvc" %} +![Reorder events](../../images/column-resize/Colum-resize-external.png) + +> The `refreshColumns` method is used to refresh the grid after the column widths are updated. Column resizing externally is useful when you want to provide a custom interface to the user for resizing columns. + +## Resizing events + +During the resizing action, the grid component triggers the below three events. + +1.The [ResizeStart](https://help.syncfusion.com/cr/aspnetmvc-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ResizeStart) event triggers when column resize starts. This event can be used to perform actions when the user begins to resize a column. + +2.The [Resizing](https://help.syncfusion.com/cr/aspnetmvc-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_Resizing) event triggers when column header element is dragged (moved) continuously. This event is useful when you want to perform certain actions during the column resize process. + +3.The [ResizeStop](https://help.syncfusion.com/cr/aspnetmvc-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ResizeStop) event triggers when column resize ends. This event can be used to perform actions after the column is resized. + +The following is an example of using the resizing events, the `ResizeStart` event is used to cancel the resizing of the **OrderID** column. The `ResizeStop` event is used to apply custom CSS attributes to the resized column. {% tabs %} -{% highlight razor tabtitle="CSHTML" %} +{% highlight cshtml tabtitle="CSHTML" %} {% include code-snippet/grid/columns/resizeevents/razor %} {% endhighlight %} -{% highlight c# tabtitle="Resizeevents.cs" %} -{% include code-snippet/grid/columns/resizeevents/resizeevents.cs %} +{% highlight c# tabtitle="Resize.cs" %} +{% include code-snippet/grid/columns/resizeevents/resize.cs %} {% endhighlight %} {% endtabs %} -{% endif %} + +![Reorder events](../../images/column-resize/Colum-resize-event.gif) + + +>The ResizeArgs object passed to the events contains information such as the current column width, new column width, column index, and the original event. The [Resizing](https://help.syncfusion.com/cr/aspnetmvc-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_Resizing) event is triggered multiple times during a single resize operation, so be careful when performing heavy operations in this event. diff --git a/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/columns/columns.md b/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/columns/columns.md index f3109a11cd..bbae0054a3 100644 --- a/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/columns/columns.md +++ b/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/columns/columns.md @@ -33,35 +33,6 @@ Grid column supports the following types: N> If the [`Type`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html#Syncfusion_EJ2_Grids_GridColumn_Type) is not defined, it will be determined from the first record of the [`DataSource`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_DataSource).
Incase if the first record of the [`DataSource`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_DataSource) is null/blank value for a column then it is necessary to define the [`Type`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html#Syncfusion_EJ2_Grids_GridColumn_Type) for that column. -## ValueAccessor - -The **valueAccessor** is used to access/manipulate the value of display data. You can achieve custom value formatting by using the valueAccessor. - -{% if page.publishingplatform == "aspnet-core" %} - -{% tabs %} -{% highlight cshtml tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/valueaccessor/tagHelper %} -{% endhighlight %} -{% highlight c# tabtitle="Valueaccessor.cs" %} -{% include code-snippet/grid/columns/valueaccessor/valueaccessor.cs %} -{% endhighlight %} -{% endtabs %} - -{% elsif page.publishingplatform == "aspnet-mvc" %} - -{% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/valueaccessor/razor %} -{% endhighlight %} -{% highlight c# tabtitle="Valueaccessor.cs" %} -{% include code-snippet/grid/columns/valueaccessor/valueaccessor.cs %} -{% endhighlight %} -{% endtabs %} -{% endif %} - - - ## Format To format cell values based on specific culture, use the [`Format`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html#Syncfusion_EJ2_Grids_GridColumn_Format) property of [`Columns`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html). The grid uses Internalization library to format number and date values. diff --git a/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/columns/complex-data-binding.md b/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/columns/complex-data-binding.md deleted file mode 100644 index b0120a7b12..0000000000 --- a/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/columns/complex-data-binding.md +++ /dev/null @@ -1,37 +0,0 @@ ---- -layout: post -title: Complex Data Binding in ##Platform_Name## Grid Component -description: Learn here all about Complex Data Binding in Syncfusion ##Platform_Name## Grid component of Syncfusion Essential JS 2 and more. -platform: ej2-asp-core-mvc -control: Complex Data Binding -publishingplatform: ##Platform_Name## -documentation: ug ---- - -# Complex Data Binding - -You can achieve complex data binding in the grid by using the dot(.) operator in the [`Field`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html#Syncfusion_EJ2_Grids_GridColumn_Field). - -{% if page.publishingplatform == "aspnet-core" %} - -{% tabs %} -{% highlight cshtml tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/complexbinding/tagHelper %} -{% endhighlight %} -{% highlight c# tabtitle="Complexbinding.cs" %} -{% include code-snippet/grid/columns/complexbinding/complexbinding.cs %} -{% endhighlight %} -{% endtabs %} - -{% elsif page.publishingplatform == "aspnet-mvc" %} - -{% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/complexbinding/razor %} -{% endhighlight %} -{% highlight c# tabtitle="Complexbinding.cs" %} -{% include code-snippet/grid/columns/complexbinding/complexbinding.cs %} -{% endhighlight %} -{% endtabs %} -{% endif %} - diff --git a/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/columns/frozen-column.md b/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/columns/frozen-column.md new file mode 100644 index 0000000000..3dd5038b98 --- /dev/null +++ b/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/columns/frozen-column.md @@ -0,0 +1,144 @@ +--- +layout: post +title: Column pinning (Frozen) in Syncfusion ##Platform_Name## Grid Component +description: Learn here all about Column pinning (Frozen) in Syncfusion ##Platform_Name## Grid component of Syncfusion Essential JS 2 and more. +platform: ej2-asp-core-mvc +control: Column pinning (Frozen) +publishingplatform: ##Platform_Name## +documentation: ug +--- + +# Column Pinning (Frozen) in ASP.NET MVC Grid component + +In the Syncfusion ASP.NET MVC Grid component, you have the capability to **freeze** columns, ensuring they remain visible as you scroll through extensive datasets. This functionality significantly improves user experience by keeping critical information constantly within view, even when navigating through large volumes of data. This means that important columns remain fixed in their positions, making it easier to access and reference key data points while working with the grid. + +In the following example, the [FrozenColumns](https://help.syncfusion.com/cr/aspnetmvc-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_FrozenColumns) property is set to **2**. This configuration freezes the left two columns of the grid, and they will remain fixed in their positions while the rest of the columns grid can be scrolled horizontally. + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/frozen-columns/razor %} +{% endhighlight %} +{% highlight c# tabtitle="Frozen.cs" %} +{% include code-snippet/grid/columns/frozen-columns/frozen.cs %} +{% endhighlight %} +{% endtabs %} + +![Column Pinning](../../images/column-chooser/frozon.png) + +> * Frozen columns should not be set outside the grid view port. +> * Frozen Grid support column virtualization feature, which helps to improve the Grid performance while loading a large dataset. +> * The frozen feature is supported only for the columns that are visible in the current view. +> * You can use both `FrozenColumns` property and [FrozenRows](https://help.syncfusion.com/cr/aspnetmvc-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_FrozenRows) property in the same application. + +## Freeze particular columns + +The Syncfusion ASP.NET MVC Grid provides a valuable feature that enables you to freeze specific columns, significantly enhancing data visibility and improving your overall user experience. This functionality allows you to select particular columns and freeze them by positioning them at the leftmost side of the grid, ensuring they remain fixed in place while the remaining grid columns can still be scrolled horizontally. While the `FrozenColumns` property freezes columns in the order they are initialized in the grid, you can also use the `IsFrozen` property at the column level to freeze a specific column at any desired index on the left side, offering flexibility in managing which columns are frozen. + +To freeze a particular column in the grid, you can utilize the `IsFrozen` property of the grid component as **true**. + +The following example demonstrates how to freeze particular column in grid using `IsFrozen` property. This is achieved by the [Change](https://help.syncfusion.com/cr/aspnetmvc-js2/Syncfusion.EJ2.DropDowns.DropDownList.html#Syncfusion_EJ2_DropDowns_DropDownList_Change) event of the `DropDownList` component. Within the change event, you can modify the `isFrozen` property of the selected column using the `getColumnByField` method. Afterward, you can use the `refreshColumns` method to update the displayed columns based on your interaction. + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/frozen-particular/razor %} +{% endhighlight %} +{% highlight c# tabtitle="Frozen.cs" %} +{% include code-snippet/grid/columns/frozen-particular/frozen.cs %} +{% endhighlight %} +{% endtabs %} + +![Freeze particular columns](../../images/column-chooser/frozon-particular.png) + +## Freeze direction + +In the Syncfusion ASP.NET MVC Grid, the "freeze direction" feature serves to reposition frozen columns either to the left, right, or in a fixed position, while still allowing the remaining columns to be horizontally movable. This feature is designed to optimize user experience by ensuring that critical information remains visible even during horizontal scrolling. By default, when you set the `FrozenColumns` property of the grid or the `IsFrozen` property of individual columns, it results in freezing those columns on the left side of the grid. This helps in keeping important data readily accessible as you navigate through your dataset. + +To achieve this, you can utilize the `Column.Freeze` property. This property is used to specify the freeze direction for individual columns. The grid will adjust the column positions based on the `Column.Freeze` value. + +The types of the `Column.Freeze` directions: + +* **Left**: When you set the `Column.Freeze` property to **Left**, specific columns will be frozen on the left side of the grid. The remaining columns will be movable. + +* **Right**: When you set the `Column.Freeze` property to **Right**, certain columns will be frozen on the right side of the grid, while the rest of the columns remain movable. + +* **Fixed**: The Fixed direction locks a column at a fixed position within the grid. This ensures that the column is always visible during horizontal scroll. + +In the following example, the **ShipCountry** column is frozen on the left side, the **CustomerID** column is frozen on the right side and the **Freight** column is frozen on the fixed of the content table. Additionally, you can modify the `Column.Freeze` property to **Left**, **Right** and **Fixed** based on the selected column by utilizing the [Change](https://help.syncfusion.com/cr/aspnetmvc-js2/Syncfusion.EJ2.DropDowns.DropDownList.html#Syncfusion_EJ2_DropDowns_DropDownList_Change) event of the `DropDownList` component. + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/frozen-direction/razor %} +{% endhighlight %} +{% highlight c# tabtitle="Frozen.cs" %} +{% include code-snippet/grid/columns/frozen-direction/frozen.cs %} +{% endhighlight %} +{% endtabs %} + +![Freeze direction](../../images/column-chooser/frozon-direction.png) + +> * Freeze Direction is not compatible with the `IsFrozen` and [FrozenColumns](https://help.syncfusion.com/cr/aspnetmvc-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_FrozenColumns) properties. + +## Change default frozen line color + +You can customize the frozen line borders of frozen columns in the Syncfusion Grid component by applying custom CSS styles to the specific frozen column. This allows you to change the border color of the left frozen columns, right frozen columns, and fixed frozen columns to match your application's design and theme. + +To change default frozen line color, use the following class name and apply the border color based on your requirement. + +For left frozen columns: + +```css +.e-grid .e-leftfreeze.e-freezeleftborder { + border-right-color: rgb(198, 30, 204); +} +``` +For right frozen columns: + +```css +.e-grid .e-rightfreeze.e-freezerightborder { + border-left-color: rgb(19, 228, 243); +} +``` +For fixed frozen columns, you need to specify both left and right border as mentioned below + +```css +.e-grid .e-fixedfreeze.e-freezeleftborder{ + border-left-color: rgb(9, 209, 9); +} + +.e-grid .e-fixedfreeze.e-freezerightborder{ + border-right-color: rgb(10, 224, 10); +} +``` +The following example demonstrates how to change the default frozen line color using CSS. + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/frozen-color/razor %} +{% endhighlight %} +{% highlight c# tabtitle="Frozen.cs" %} +{% include code-snippet/grid/columns/frozen-color/frozen.cs %} +{% endhighlight %} +{% endtabs %} + +![Change default frozen line color](../../images/column-chooser/frozon-color.png) + +## Deprecated methods + +Previous | Current | Explanation + --- | --- | --- +`getMovableRows()` gridInstance.getMovableRows()[0].querySelectorAll('.e-unfreeze') | `getRows()` gridInstance.getRows()[0].querySelectorAll('.e-unfreeze') | The previous architecture used separate tables for left, right, and movable contents, returning only movable rows when calling the method, whereas the current architecture combines them into one table, returning all rows and introduces the `e-unfreeze` class for selecting movable rows +`getFrozenRightRows()` gridInstance.getFrozenRightRows()[0].querySelectorAll('.e-rightfreeze') | `getRows()` gridInstance.getRows()[0].querySelectorAll('.e-rightfreeze') | In the previous architecture, it returned only the table rows from the right freeze table, but in the current architecture, all rows of the entire table are returned, introducing the `e-rightfreeze` class for selecting right freeze rows. +`getMovableRowByIndex()`
`getFrozenRowByIndex()`
`getFrozenRightRowByIndex()` | `getRowByIndex()` gridInstance.getRowByIndex(1).querySelectorAll('.e-unfreeze') | In the previous architecture, separate methods were used to select rows from different table sections, while in the current architecture, the `getMovableRowByIndex()`, `getFrozenRightRowByIndex()`, and `getFrozenRowByIndex()` methods now return the same table row based on the given index. Additionally, class names for table cells (td's) have been separated into `e-leftfreeze`, `e-unfreeze`, and `e-rightfreeze`, making it easier to customize cells within a row. +`getMovableCellFromIndex()`
`getFrozenRightCellFromIndex()` | `getCellFromIndex()` gridInstance.getCellFromIndex(1,1) | In the previous approach, the `getMovableCellFromIndex()` method was used to choose a specific cell within the movable table, and the `getFrozenRightCellFromIndex()` method was utilized to target a particular cell within the right freeze table. However, in the current architecture, you have the flexibility to select a specific cell in either the movable or right freeze table by using both the `getFrozenRightCellFromIndex()` and `getMovableCellFromIndex()` methods. This new method simplifies the process of selecting and retrieving specific cells within these tables, offering more versatility and convenience. +`getMovableDataRows()`
`getFrozenRightDataRows()`
`getFrozenDataRows()` | `getDataRows()` gridInstance.getDataRows()[0].querySelectorAll('.e-unfreeze') | In the previous approach, there were separate methods (`getMovableDataRows()`, `getFrozenRightDataRows()`, and `getFrozenDataRows()`) for obtaining viewport data rows from the freeze, movable, and right tables individually. However, in the new approach, these methods have been enhanced to return the entire viewport data rows for all sections together, simplifying data retrieval. You can now extract specific cells within these rows using selectors such as `e-leftfreeze` for the **left freeze**, `e-unfreeze` for the **movable**, and `e-rightfreeze` for the **right freeze** tables, providing greater flexibility in working with the data. +`getMovableColumnHeaderByIndex()`
`getFrozenRightColumnHeaderByIndex()`
`getFrozenLeftColumnHeaderByIndex()` | `getColumnHeaderByIndex()` gridInstance.getColumnHeaderByIndex(1) | In the previous architecture, the methods selected movable, right freeze, and left freeze headers separately. However, in the new approach, when using the `getMovableColumnHeaderByIndex()`, `getFrozenRightColumnHeaderByIndex()`, and `getFrozenLeftColumnHeaderByIndex()` methods, you will still obtain the same results as in the previous architecture. + +> When a validation message is displayed in the frozen part (Left, Right, Fixed) of the table, scrolling is prevented until the validation message is cleared. + +## Limitations + +While freezing columns in the Syncfusion ASP.NET MVC Grid provides enhanced visibility and scrolling capabilities, there are certain limitations to consider. The following features are not supported when using frozen columns: + +* Detail Template +* Hierarchy Grid +* Autofill \ No newline at end of file diff --git a/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/columns/headers.md b/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/columns/headers.md deleted file mode 100644 index 6086316eb6..0000000000 --- a/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/columns/headers.md +++ /dev/null @@ -1,176 +0,0 @@ ---- -layout: post -title: Headers in ##Platform_Name## Grid Component -description: Learn here all about Headers in Syncfusion ##Platform_Name## Grid component of Syncfusion Essential JS 2 and more. -platform: ej2-asp-core-mvc -control: Headers -publishingplatform: ##Platform_Name## -documentation: ug ---- - -# Headers - -## Header text - -By default, column header title is displayed from column [`Field`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html#Syncfusion_EJ2_Grids_GridColumn_Field) value. To override the default header title, you have to define the [`HeaderText`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html#Syncfusion_EJ2_Grids_GridColumn_HeaderText) value. - -{% if page.publishingplatform == "aspnet-core" %} - -{% tabs %} -{% highlight cshtml tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/headertext/tagHelper %} -{% endhighlight %} -{% highlight c# tabtitle="Headertext.cs" %} -{% include code-snippet/grid/columns/headertext/headertext.cs %} -{% endhighlight %} -{% endtabs %} - -{% elsif page.publishingplatform == "aspnet-mvc" %} - -{% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/headertext/razor %} -{% endhighlight %} -{% highlight c# tabtitle="Headertext.cs" %} -{% include code-snippet/grid/columns/headertext/headertext.cs %} -{% endhighlight %} -{% endtabs %} -{% endif %} - - - -N> If both the [`Field`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html#Syncfusion_EJ2_Grids_GridColumn_Field) and [`HeaderText`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html#Syncfusion_EJ2_Grids_GridColumn_HeaderText) are not defined in the column, the column renders with empty header text. - -## Header template - -You can customize the header element by using the [`HeaderTemplate`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html#Syncfusion_EJ2_Grids_GridColumn_HeaderTemplate) property. In this demo, the custom element is rendered for both EmployeeID and BirthDate column headers. - -{% if page.publishingplatform == "aspnet-core" %} - -{% tabs %} -{% highlight cshtml tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/headertemplate/tagHelper %} -{% endhighlight %} -{% highlight c# tabtitle="Headertemplate.cs" %} -{% include code-snippet/grid/columns/headertemplate/headertemplate.cs %} -{% endhighlight %} -{% endtabs %} - -{% elsif page.publishingplatform == "aspnet-mvc" %} - -{% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/headertemplate/razor %} -{% endhighlight %} -{% highlight c# tabtitle="Headertemplate.cs" %} -{% include code-snippet/grid/columns/headertemplate/headertemplate.cs %} -{% endhighlight %} -{% endtabs %} -{% endif %} - - - -## Change header text dynamically - -You can change the column [`HeaderText`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html#Syncfusion_EJ2_Grids_GridColumn_HeaderText) dynamically through an external button. - -Follow the given steps to change the header text dynamically: - -**Step 1**: Get the column object corresponding to the field name by using the [`getColumnByField`](https://ej2.syncfusion.com/documentation/api/grid/#getcolumnbyfield) method. Then, change the header text value. - -```typescript -var column = grid.getColumnByField("ShipCity"); // Get column object. -column.headerText = 'Changed Text'; - -``` - -**Step 2**: To reflect the changes in the grid header, invoke the [`refreshHeader`](https://ej2.syncfusion.com/documentation/api/grid/#refreshheader) method. - -```typescript -grid.refreshHeader(); - -``` - -{% if page.publishingplatform == "aspnet-core" %} - -{% tabs %} -{% highlight cshtml tabtitle="CSHTML" %} -{% include code-snippet/grid/how-to/column-header-text/tagHelper %} -{% endhighlight %} -{% highlight c# tabtitle="Column-header-text.cs" %} -{% include code-snippet/grid/how-to/column-header-text/column-header-text.cs %} -{% endhighlight %} -{% endtabs %} - -{% elsif page.publishingplatform == "aspnet-mvc" %} - -{% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/grid/how-to/column-header-text/razor %} -{% endhighlight %} -{% highlight c# tabtitle="Column-header-text.cs" %} -{% include code-snippet/grid/how-to/column-header-text/column-header-text.cs %} -{% endhighlight %} -{% endtabs %} -{% endif %} - - - -## Change the orientation of header Text - -You can change the orientation of the header text by using the [`CustomAttributes`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html#Syncfusion_EJ2_Grids_GridColumn_CustomAttributes) property. - -Ensure the following steps: - -**Step 1**: Create a CSS class with orientation style for the grid header cell. - -```css -.orientationcss .e-headercelldiv { - transform: rotate(90deg); -} - -``` - -**Step 2**: Add the custom CSS class to a particular column by using the [`CustomAttributes`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html#Syncfusion_EJ2_Grids_GridColumn_CustomAttributes) property. - -```typescript - - -``` - -**Step 3**: Resize the header cell height by using the following code. - -```typescript -function setHeaderHeight(args) { - var textWidth = document.querySelector(".orientationcss > div").scrollWidth;//Obtain the width of the headerText content. - var headerCell = document.querySelectorAll(".e-headercell"); - for(var i = 0; i < headerCell.length; i++) { - headerCell.item(i).style.height = textWidth + 'px'; //Assign the obtained textWidth as the height of the headerCell. - } -} - -``` - -{% if page.publishingplatform == "aspnet-core" %} - -{% tabs %} -{% highlight cshtml tabtitle="CSHTML" %} -{% include code-snippet/grid/how-to/orientation/tagHelper %} -{% endhighlight %} -{% highlight c# tabtitle="Orientation.cs" %} -{% include code-snippet/grid/how-to/orientation/orientation.cs %} -{% endhighlight %} -{% endtabs %} - -{% elsif page.publishingplatform == "aspnet-mvc" %} - -{% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/grid/how-to/orientation/razor %} -{% endhighlight %} -{% highlight c# tabtitle="Orientation.cs" %} -{% include code-snippet/grid/how-to/orientation/orientation.cs %} -{% endhighlight %} -{% endtabs %} -{% endif %} - diff --git a/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/print.md b/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/print.md index 88e4803e8c..f146e2c82b 100644 --- a/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/print.md +++ b/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/print.md @@ -8,227 +8,182 @@ publishingplatform: ##Platform_Name## documentation: ug --- +# Print in ASP.NET MVC Grid component -# Print in ASP.NET MVC Grid Component +The printing feature in Syncfusion Grid allows you to easily generate and print a representation of the grid's content for better offline accessibility and documentation. You can enable this feature using either the grid's toolbar or the programmatically available `print` method. -To print the Grid, use the [`print`](https://ej2.syncfusion.com/documentation/api/grid/#print) method from grid instance. The print option can be displayed on the [`Toolbar`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_Toolbar) by adding the **Print** toolbar item. - -{% if page.publishingplatform == "aspnet-core" %} +To add the printing option to the grid's toolbar, simply include the [Toolbar](https://help.syncfusion.com/cr/aspnetmvc-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_Toolbar) property in your grid configuration and add the **Print** as toolbar item. This will allow you to directly initiate the printing process while click on the Print item from the toolbar. {% tabs %} {% highlight cshtml tabtitle="CSHTML" %} -{% include code-snippet/grid/print/print/tagHelper %} -{% endhighlight %} -{% highlight c# tabtitle="Print.cs" %} -{% include code-snippet/grid/print/print/print.cs %} -{% endhighlight %} -{% endtabs %} - -{% elsif page.publishingplatform == "aspnet-mvc" %} - -{% tabs %} -{% highlight razor tabtitle="CSHTML" %} {% include code-snippet/grid/print/print/razor %} {% endhighlight %} -{% highlight c# tabtitle="Print.cs" %} +{% highlight c# tabtitle="print.cs" %} {% include code-snippet/grid/print/print/print.cs %} {% endhighlight %} {% endtabs %} -{% endif %} - +![Print](../images/print/print.png) ## Page setup -Some of the print options cannot be configured through JavaScript code. So, you have to customize the layout, paper size, and margin options using the browser page setup dialog. Refer to the following links to know more about the browser page setup: - -* [`Chrome`](https://support.google.com/chrome/answer/1069693?hl=en&visit_id=1-636335333734668335-3165046395&rd=1) -* [`Firefox`](https://support.mozilla.org/en-US/kb/how-print-web-pages-firefox) -* [`Safari`](http://www.mintprintables.com/print-tips/adjust-margins-osx/) -* [`IE`](http://www.helpteaching.com/help/print/index.htm) +When printing a webpage, some print options, such as layout, paper size, and margin settings, cannot be configured through JavaScript code. Instead, you need to customize these settings using the browser's page setup dialog. Below are links to the page setup guides for popular web browsers: -## Print using an external button +* [Chrome](https://support.google.com/chrome/answer/1069693?hl=en&visit_id=1-636335333734668335-3165046395&rd=1) +* [Firefox](https://support.mozilla.org/en-US/kb/how-print-web-pages-firefox) +* [Safari](http://www.mintprintables.com/print-tips/adjust-margins-osx/) +* [IE](http://www.helpteaching.com/help/print/index.htm) -To print the grid from an external button, invoke the [`print`](https://ej2.syncfusion.com/documentation/api/grid/#print) method. +## Print by external button -{% if page.publishingplatform == "aspnet-core" %} +You can print the grid's content using an external button by utilizing the `print` method. This method allows you to trigger the printing process programmatically. {% tabs %} {% highlight cshtml tabtitle="CSHTML" %} -{% include code-snippet/grid/print/external-btn/tagHelper %} -{% endhighlight %} -{% highlight c# tabtitle="External-btn.cs" %} -{% include code-snippet/grid/print/external-btn/external-btn.cs %} -{% endhighlight %} -{% endtabs %} - -{% elsif page.publishingplatform == "aspnet-mvc" %} - -{% tabs %} -{% highlight razor tabtitle="CSHTML" %} {% include code-snippet/grid/print/external-btn/razor %} {% endhighlight %} {% highlight c# tabtitle="External-btn.cs" %} {% include code-snippet/grid/print/external-btn/external-btn.cs %} {% endhighlight %} {% endtabs %} -{% endif %} - - -## Print the visible page +![Print by external button](../images/print/print-external.png) -By default, the grid prints all the pages. To print the current page alone, set the [`PrintMode`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_PrintMode) to **CurrentPage**. +## Print visible Page -{% if page.publishingplatform == "aspnet-core" %} +By default, the Syncfusion ASP.NET MVC Grid prints all the pages of the grid. The [PrintMode](https://help.syncfusion.com/cr/aspnetmvc-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_PrintMode) property within the grid grants you control over the printing process. However, if you want to print only the current visible page, you can achieve this by setting the `PrintMode` property to **CurrentPage**. {% tabs %} {% highlight cshtml tabtitle="CSHTML" %} -{% include code-snippet/grid/print/current-page/tagHelper %} +{% include code-snippet/grid/print/current-page/razor %} {% endhighlight %} {% highlight c# tabtitle="Current-page.cs" %} {% include code-snippet/grid/print/current-page/current-page.cs %} {% endhighlight %} {% endtabs %} -{% elsif page.publishingplatform == "aspnet-mvc" %} +![Print visible Page](../images/print/print-current.png) + +## Print only selected records + +By default, the Syncfusion ASP.NET MVC Grid prints all the data bound to its dataSource. However, there might be cases where you want to print only the selected records from the grid. The ASP.NET MVC Grid provides an option to achieve this by binding to the [BeforePrint](https://help.syncfusion.com/cr/aspnetmvc-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_BeforePrint) event, where you can replace the rows of the printing grid with the selected rows. + +Below is an example code that demonstrates how to print only the selected records from the ASP.NET MVC Grid: {% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/grid/print/current-page/razor %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/print/print-select/razor %} {% endhighlight %} -{% highlight c# tabtitle="Current-page.cs" %} -{% include code-snippet/grid/print/current-page/current-page.cs %} +{% highlight c# tabtitle="Print.cs" %} +{% include code-snippet/grid/print/print-select/print.cs %} {% endhighlight %} {% endtabs %} -{% endif %} - +![Print only selected records](../images/print/print-select.png) ## Print the hierarchy grid -By default, the grid will be print the master and expanded child grids alone. you can change the print option by using the [`hierarchyPrintMode`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_HierarchyPrintMode) property. The available options are, +The Syncfusion ASP.NET MVC Grid allows you to print hierarchy grids, which consist of a parent grid and its child grids. By default, when you print a hierarchy grid, it includes the parent grid and expanded child grids only. However, you can customize the print behavior using the [HierarchyPrintMode](https://help.syncfusion.com/cr/aspnetmvc-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_HierarchyPrintMode) property. -| Mode | Behavior | -|----------|-------------| -| Expanded | Prints the master grid with expanded child grids. | -| All | Prints the master grid with all the child grids. | -| None | Prints the master grid alone. | +The `HierarchyPrintMode` property in the ASP.NET MVC Grid lets you control the printing behavior for hierarchy grids. You can choose from three options: -{% if page.publishingplatform == "aspnet-core" %} +| Mode | Behavior | +| -------- | ------------------------------------------------------------------------------- | +| Expanded | Prints the parent grid with expanded child grids. | +| All | Prints the parent grid with all the child grids, whether expanded or collapsed. | +| None | Prints the parent grid alone. | {% tabs %} -{% highlight c# tabtitle="CSHTML" %} -{% include code-snippet/grid/print/hierarchyprint/tagHelper %} -{% endhighlight %} -{% highlight c# tabtitle="Hierarchyprint.cs" %} -{% include code-snippet/grid/print/hierarchyprint/hierarchyprint.cs %} -{% endhighlight %} -{% highlight c# tabtitle="Hierarchyprint.cs" %} -{% include code-snippet/grid/print/hierarchyprint/hierarchyprint.cs %} -{% endhighlight %} -{% endtabs %} - -{% elsif page.publishingplatform == "aspnet-mvc" %} - -{% tabs %} -{% highlight razor tabtitle="CSHTML" %} +{% highlight cshtml tabtitle="CSHTML" %} {% include code-snippet/grid/print/hierarchyprint/razor %} {% endhighlight %} {% highlight c# tabtitle="Hierarchyprint.cs" %} {% include code-snippet/grid/print/hierarchyprint/hierarchyprint.cs %} {% endhighlight %} -{% highlight c# tabtitle="Hierarchyprint.cs" %} -{% include code-snippet/grid/print/hierarchyprint/hierarchyprint.cs %} -{% endhighlight %} {% endtabs %} -{% endif %} - - -N> By default, the hierarchy grid prints the expanded child grids from the visible page only. Refer [To Print the expanded state grid from all pages](./how-to/#print-the-expanded-state-from-other-pages). +![Print the hierarchy grid](../images/print/print-hierachy.png) ## Print the master detail grid -The Grid has the option to visualize details of a record in another Grid in a master and detailed manner. By default, Grid will print the master grid alone. Instead of this, it is possible to print both the master and detail grids by using the [BeforePrint](https://help.syncfusion.com/cr/aspnetmvc-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_BeforePrint) event of the Grid. - -In the following sample, the detail grid is added to the `element` argument of the `BeforePrint` event, resulting in both the master and detail grids being printed on the page. +The Syncfusion ASP.NET MVC Grid provides the option to visualize details of a record in another grid in a master-detail manner. By default, when you print a master-detail grid, only the master grid is included in the print output. However, you can customize the print behavior to include both the master and detail grids using the `BeforePrint` event of the grid. -{% if page.publishingplatform == "aspnet-core" %} +The [BeforePrint](https://help.syncfusion.com/cr/aspnetmvc-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_BeforePrint)event in the ASP.NET MVC Grid is triggered before the actual printing process begins. You can handle this event to customize the print output. By adding the detail grid to the `element` argument of the `BeforePrint` event, you can ensure that both the master and detail grids are printed on the page. {% tabs %} {% highlight cshtml tabtitle="CSHTML" %} -{% include code-snippet/grid/print/masterdetailgrid/tagHelper %} -{% endhighlight %} -{% highlight c# tabtitle="Master-Detail.cs" %} -{% include code-snippet/grid/print/masterdetailgrid/masterdetailgrid.cs %} -{% endhighlight %} -{% endtabs %} - -{% elsif page.publishingplatform == "aspnet-mvc" %} - -{% tabs %} -{% highlight razor tabtitle="CSHTML" %} {% include code-snippet/grid/print/masterdetailgrid/razor %} {% endhighlight %} {% highlight c# tabtitle="Master-Detail.cs" %} {% include code-snippet/grid/print/masterdetailgrid/masterdetailgrid.cs %} {% endhighlight %} {% endtabs %} -{% endif %} +![Print the master detail grid](../images/print/print-master.png) ## Print large number of columns -By default, the browser uses A4 as page size option to print pages and to adapt the size of the page the browser print preview will auto-hide the overflowed contents. Hence grid with large number of columns will cut off to adapt the print page. - -To show large number of columns when printing, adjust the scale option from print option panel based on your content size. +When printing a grid with a large number of columns, the browser's default page size (usually A4) might not be sufficient to display all the columns properly. As a result, the browser's print preview may automatically hide the overflowed content, leading to a cut-off appearance. -![Scale Option Setting](./images/print-preview.png) +To show a large number of columns when printing, you can adjust the scale option from the print option panel based on your content size. This will allow you to fit the entire grid content within the printable area. -## Show or Hide columns while Printing +![Scale Option Setting](../images/print-preview.png) -You can show a hidden column or hide a visible column while printing the grid using [`ToolbarClick`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ToolbarClick) and [`PrintComplete`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_PrintComplete) events. +## Show or hide columns while printing -In the [`ToolbarClick`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ToolbarClick) event, based on **args.item.id** as **grid_print**. We can show or hide columns by setting [`Visible`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html#Syncfusion_EJ2_Grids_GridColumn_Visible) property of [`Column`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html) to **true** or **false** respectively. +In the Syncfusion ASP.NET MVC Grid, you have the flexibility to control the visibility of columns during the printing process. You can dynamically show or hide specific columns using the [ToolbarClick](https://help.syncfusion.com/cr/aspnetmvc-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_ToolbarClick) and [PrintComplete](https://help.syncfusion.com/cr/aspnetmvc-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_PrintComplete) events while printing. This capability enhances your control over which columns are included in the printed output, allowing you to tailor the printed grid to your specific needs. -In the [`PrintComplete`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_PrintComplete) event, We have reversed the state back to the previous state. +In the `ToolbarClick` event, you can show or hide columns by setting `Column.Visible` property to **true** or **false** respectively. -In the below example, we have **CustomerID** as a hidden column in the grid. While printing, we have changed **CustomerID** to visible column and **ShipCity** as hidden column. +In the `PrintComplete` event, the column visibility state is reset back to its original configuration. -{% if page.publishingplatform == "aspnet-core" %} +Here's a code example that demonstrates how to show a hidden column (CustomerID) and hide a visible column (ShipCity) during printing and then reset their visibility after printing: {% tabs %} {% highlight cshtml tabtitle="CSHTML" %} -{% include code-snippet/grid/print/show-hide-columns/tagHelper %} +{% include code-snippet/grid/print/show-hide-columns/razor %} {% endhighlight %} {% highlight c# tabtitle="Show-hide.cs" %} {% include code-snippet/grid/print/show-hide-columns/show-hide.cs %} {% endhighlight %} {% endtabs %} -{% elsif page.publishingplatform == "aspnet-mvc" %} +![Show or hide columns while printing](../images/print/print-hide.png) + +## Limitations of printing large data + +Printing a large volume of data all at once in the grid can have certain limitations due to potential browser performance issues. Rendering numerous DOM elements on a single page can lead to browser slowdowns or even hang the browser. The grid offers a solution to manage extensive datasets through virtualization. However, it's important to note that virtualization for both rows and columns is not feasible during the printing process. + +If printing all the data remains a requirement, an alternative approach is recommended. Exporting the grid data to formats like [Excel](https://ej2.syncfusion.com/aspnetcore/documentation/grid/excel-export/excel-exporting) or [CSV](https://ej2.syncfusion.com/aspnetcore/documentation/grid/excel-export/excel-exporting) or [Pdf](https://ej2.syncfusion.com/aspnetcore/documentation/grid/pdf-export/pdf-export) is advised. This exported data can then be printed using non-web-based applications, mitigating the potential performance challenges associated with printing large datasets directly from the browser. + +## Retain grid styles while printing + +The Syncfusion ASP.NET MVC Grid provides a [BeforePrint](https://help.syncfusion.com/cr/aspnetmvc-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_BeforePrint) event that allows you to customize the appearance and styles of the grid before it is sent to the printer. By handling this event, you can ensure that the grid retains its styles and appearance while printing. {% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/grid/print/show-hide-columns/razor %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/print/print-style/razor %} {% endhighlight %} -{% highlight c# tabtitle="Show-hide.cs" %} -{% include code-snippet/grid/print/show-hide-columns/show-hide.cs %} +{% highlight c# tabtitle="print.cs" %} +{% include code-snippet/grid/print/print-style/print.cs %} {% endhighlight %} {% endtabs %} -{% endif %} +![Retain grid styles while printing](../images/print/print-style.png) +## Print grid along with other components -## Limitations of Printing Large Data +To print the Syncfusion ASP.NET MVC Grid along with another component, such as a chart, you can use the [BeforePrint](https://help.syncfusion.com/cr/aspnetmvc-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_BeforePrint) event of the grid. In this event, you can clone the content of the other component and append it to the print document. -When grid contains large number of data, printing all the data at once is not a best option for the browser performance. Because to render all the DOM elements in one page will produce performance issues in the browser. It leads to browser slow down or browser hang. Grid have option to handle large number of data by Virtualization. However while printing, it is not possible to use virtualization for rows and columns. +Here is an example of how to print grid along with chart component: -If printing of all the data is still needed, we suggest to Export the grid to **Excel** or **CSV** or **Pdf** and then print it from another non-web based application. - -## See Also +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/print/print-custom/razor %} +{% endhighlight %} +{% highlight c# tabtitle="print.cs" %} +{% include code-snippet/grid/print/print-custom/print.cs %} +{% endhighlight %} +{% endtabs %} -* [How to Print the expanded state grid from all pages](./how-to/print-the-expanded-state-from-other-pages) -* [How to print the Grid using external button in ASP.NET MVC Grid](https://www.syncfusion.com/forums/136763/how-to-print-the-grid-using-external-button-in-asp-net-mvc-grid) -* [How to print the custom report in ASP.NET MVC Grid](https://www.syncfusion.com/forums/141249/how-to-print-the-custom-report-in-asp-net-mvc-grid) \ No newline at end of file +![Print grid along with other components](../images/print/print-custom.png) \ No newline at end of file diff --git a/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/cell.md b/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/cell.md index 5c661011a9..c182fe85d8 100644 --- a/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/cell.md +++ b/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/cell.md @@ -8,9 +8,9 @@ publishingplatform: ##Platform_Name## documentation: ug --- -# Cell in ##Platform_Name## Syncfusion Grid component +# Cell in ASP.NET Core Syncfusion Grid component -In the Syncfusion ##Platform_Name## Grid, a **cell** refers to an individual data point or a unit within a grid column that displays data. It represents the intersection of a row and a column, and it contains specific information associated with that row and column. Each cell can display text, numbers, or other content related to the data it represents. +In the Syncfusion ASP.NET Core Grid, a **cell** refers to an individual data point or a unit within a grid column that displays data. It represents the intersection of a row and a column, and it contains specific information associated with that row and column. Each cell can display text, numbers, or other content related to the data it represents. The Grid component allows you to customize the appearance and behavior of cells using various features and options. You can define templates, format cell values, enable or disable editing, and perform various other operations on the cells to create interactive and informative data grids in your web applications. diff --git a/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/columns/auto-generated-columns.md b/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/columns/auto-generated-columns.md deleted file mode 100644 index 903ecbce61..0000000000 --- a/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/columns/auto-generated-columns.md +++ /dev/null @@ -1,103 +0,0 @@ ---- -layout: post -title: Auto Generated Columns in ##Platform_Name## Grid Control | Syncfusion -description: Learn here all about Auto Generated Columns in Syncfusion ##Platform_Name## Grid component of Syncfusion Essential JS 2 and more. -platform: ej2-asp-core-mvc -control: Auto Generated Columns -publishingplatform: ##Platform_Name## -documentation: ug ---- - -# Auto Generated Columns - -The [`Columns`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_Columns) are automatically generated when [`Columns`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_Columns) declaration is empty or undefined while initializing the grid. All the columns in the **DataSource** are bound as grid columns. - -{% if page.publishingplatform == "aspnet-core" %} - -{% tabs %} -{% highlight cshtml tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/auto/tagHelper %} -{% endhighlight %} -{% highlight c# tabtitle="Auto.cs" %} -{% include code-snippet/grid/columns/auto/auto.cs %} -{% endhighlight %} -{% endtabs %} - -{% elsif page.publishingplatform == "aspnet-mvc" %} - -{% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/auto/razor %} -{% endhighlight %} -{% highlight c# tabtitle="Auto.cs" %} -{% include code-snippet/grid/columns/auto/auto.cs %} -{% endhighlight %} -{% endtabs %} -{% endif %} - - - -N> When columns are auto-generated, the column [`Type`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html#Syncfusion_EJ2_Grids_GridColumn_Type) will be determined from the first record of the **DataSource**. - -## Set Primary key column for auto generated columns when editing is enabled - -Primary key can be defined in the declaration of column object of the grid. If you did not declare the columns, the grid will generate the columns automatically. For these auto generated columns, you can set [`isPrimaryKey`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html#Syncfusion_EJ2_Grids_GridColumn_IsPrimaryKey) property of **e-grid-column** as true by using the following ways, - -If Primary key "column index" is known then refer the following example - -{% if page.publishingplatform == "aspnet-core" %} - -{% tabs %} -{% highlight cshtml tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/primary/tagHelper %} -{% endhighlight %} -{% highlight c# tabtitle="Primary.cs" %} -{% include code-snippet/grid/columns/primary/primary.cs %} -{% endhighlight %} -{% endtabs %} - -{% elsif page.publishingplatform == "aspnet-mvc" %} - -{% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/primary/razor %} -{% endhighlight %} -{% highlight c# tabtitle="Primary.cs" %} -{% include code-snippet/grid/columns/primary/primary.cs %} -{% endhighlight %} -{% endtabs %} -{% endif %} - - - -N> If Primary key "column fieldname" is known then you can get the column by using `var column = grid.getColumnByField('OrderID')` and then set primary key by defining [`isPrimaryKey`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html#Syncfusion_EJ2_Grids_GridColumn_IsPrimaryKey) property as true in **e-grid-column** tag helper. - -## Set column options to auto generated columns - -You can set column options such as [`format`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html#Syncfusion_EJ2_Grids_GridColumn_Format), [`width`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html#Syncfusion_EJ2_Grids_GridColumn_Width) to the auto generated columns by using [`dataBound`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_DataBound) event of the grid. - -In the below example, [`width`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html#Syncfusion_EJ2_Grids_GridColumn_Width) is set for **OrderID** column, **date** type is set for **OrderDate** column and **numeric** type is set for **Freight** column. - -{% if page.publishingplatform == "aspnet-core" %} - -{% tabs %} -{% highlight cshtml tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/autocolumnformat/tagHelper %} -{% endhighlight %} -{% highlight c# tabtitle="Autocolumnformat.cs" %} -{% include code-snippet/grid/columns/autocolumnformat/autocolumnformat.cs %} -{% endhighlight %} -{% endtabs %} - -{% elsif page.publishingplatform == "aspnet-mvc" %} - -{% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/autocolumnformat/razor %} -{% endhighlight %} -{% highlight c# tabtitle="Autocolumnformat.cs" %} -{% include code-snippet/grid/columns/autocolumnformat/autocolumnformat.cs %} -{% endhighlight %} -{% endtabs %} -{% endif %} - diff --git a/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/columns/column-chooser.md b/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/columns/column-chooser.md index 5f4e44d9d7..282135dbc4 100644 --- a/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/columns/column-chooser.md +++ b/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/columns/column-chooser.md @@ -8,11 +8,9 @@ publishingplatform: ##Platform_Name## documentation: ug --- -# Column Chooser +# Column chooser in ASP.NET Core Grid component -The column chooser has options to show or hide columns dynamically. It can be enabled by defining the [`showColumnChooser`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ShowColumnChooser) property as true. - -{% if page.publishingplatform == "aspnet-core" %} +The column chooser feature in the Syncfusion ASP.NET Core Grid component allows you to dynamically show or hide columns. This feature can be enabled by defining the [showColumnChooser](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ShowColumnChooser) property as **true**. {% tabs %} {% highlight cshtml tabtitle="CSHTML" %} @@ -23,46 +21,105 @@ The column chooser has options to show or hide columns dynamically. It can be en {% endhighlight %} {% endtabs %} -{% elsif page.publishingplatform == "aspnet-mvc" %} +![Column chooser](../../images/column-chooser/Colum-chooser.png) + +> The column chooser dialog displays the header text of each column by default. If the header text is not defined for a column, the corresponding column field name is displayed instead. + +## Hide column in column chooser dialog + +You can hide the column names in column chooser by defining the `columns.showInColumnChooser` as **false**. This feature is useful when working with a large number of columns or when you want to limit the number of columns that are available for selection in the column chooser dialog. + +In this example, the `columns.showInColumnChooser` property is set to **false** for the **Order ID** column. As a result, the **Order ID** column will not be displayed in the column chooser dialog. {% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/columnchooser/razor %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/columnchooser-hide/tagHelper %} {% endhighlight %} {% highlight c# tabtitle="Columnchooser.cs" %} -{% include code-snippet/grid/columns/columnchooser/columnchooser.cs %} +{% include code-snippet/grid/columns/columnchooser-hide/columnchooser.cs %} +{% endhighlight %} +{% endtabs %} + +![Hide column in column chooser dialog](../../images/column-chooser/Colum-chooser-hide.png) + +>The `columns.showInColumnChooser` property is applied to each element individually. By setting it to **false**, you can hide specific columns from the column chooser dialog. + +## Open column chooser by externally + +The Syncfusion ASP.NET Core Grid provides the flexibility to open the column chooser dialog on a web page using an external button. By default, the column chooser button is displayed in the right corner of the grid component, and clicking the button opens the column chooser dialog below it. However, you can programmatically open the column chooser dialog at specific **X** and **Y** axis positions by using the `openColumnChooser` method. + +Here's an example of how to open the column chooser in the Grid using an external button: + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/columnchooser-external/tagHelper %} +{% endhighlight %} +{% highlight c# tabtitle="Columnchooser.cs" %} +{% include code-snippet/grid/columns/columnchooser-external/columnchooser.cs %} {% endhighlight %} {% endtabs %} -{% endif %} +![Open column chooser by externally](../../images/column-chooser/Colum-chooser-external.png) + +## Customize column chooser dialog size + +The column chooser dialog in Syncfusion ASP.NET Core Grid comes with default size, but you can modify its height and width as per your specific needs using CSS styles. +To customize the column chooser dialog size, you can use the following CSS styles: +```css +.e-grid .e-dialog.e-ccdlg { + height: 500px; + width: 200px; +} +.e-grid .e-ccdlg .e-cc-contentdiv { + height: 200px; + width: 230px; +} +``` -N> You can hide the column names in column chooser by defining the [`showInColumnChooser`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html#Syncfusion_EJ2_Grids_GridColumn_ShowInColumnChooser) property as false in **e-grid-column** tag helper of particular column. +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/columnchooser-size/tagHelper %} +{% endhighlight %} +{% highlight c# tabtitle="Columnchooser.cs" %} +{% include code-snippet/grid/columns/columnchooser-size/columnchooser.cs %} +{% endhighlight %} +{% endtabs %} -## Open column chooser by external button +![Customize column chooser dialog size](../../images/column-chooser/Colum-chooser-size.png) -The Column chooser can be displayed on a page through external button by invoking the **openColumnChooser** method with **X** and **Y** axis positions. +## Change default search operator of the column chooser -{% if page.publishingplatform == "aspnet-core" %} +The column chooser dialog in the Syncfusion ASP.NET Core Grid provides a search box that allows you to search for column names. By default, the search functionality uses the "startsWith" operator to match columns and display the results in the column chooser dialog. However, there might be cases where you need to change the default search operator to achieve more precise data matching. + +To change the default search operator of the column chooser in Syncfusion Grid, you need to use the [operator](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumnChooserSettings.html#Syncfusion_EJ2_Grids_GridColumnChooserSettings_Operator) property of the columnChooserSettings. + +Here's an example of how to change the default search operator of the column chooser to **contains** in the ASP.NET Core Grid: {% tabs %} {% highlight cshtml tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/externalbutton/tagHelper %} +{% include code-snippet/grid/columns/columnchooser-contains/tagHelper %} {% endhighlight %} -{% highlight c# tabtitle="Externalbutton.cs" %} -{% include code-snippet/grid/columns/externalbutton/externalbutton.cs %} +{% highlight c# tabtitle="Columnchooser.cs" %} +{% include code-snippet/grid/columns/columnchooser-contains/columnchooser.cs %} {% endhighlight %} {% endtabs %} -{% elsif page.publishingplatform == "aspnet-mvc" %} +![Change default search operator of the column chooser ](../../images/column-chooser/Colum-chooser-contains.png) + +## Diacritics searching in column chooser + +By default, the grid ignores diacritic characters when performing a search in the column chooser. However, in some cases, you may want to include diacritic characters in the search. To enable this behavior, you can set the [columnchoosersettings.ignoreAccent](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumnChooserSettings.html#Syncfusion_EJ2_Grids_GridColumnChooserSettings_IgnoreAccent) property to **true**. + +Here is an example that demonstrates the usage of the `ignoreAccent` property to include diacritic characters for searching in the column chooser: {% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/externalbutton/razor %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/columnchooser-diacritics/tagHelper %} {% endhighlight %} -{% highlight c# tabtitle="Externalbutton.cs" %} -{% include code-snippet/grid/columns/externalbutton/externalbutton.cs %} +{% highlight c# tabtitle="Columnchooser.cs" %} +{% include code-snippet/grid/columns/columnchooser-diacritics/columnchooser.cs %} {% endhighlight %} {% endtabs %} -{% endif %} +![Diacritics searching in column chooser](../../images/columns/Column-headertext.png) \ No newline at end of file diff --git a/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/columns/column-headers.md b/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/columns/column-headers.md new file mode 100644 index 0000000000..ada4100eae --- /dev/null +++ b/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/columns/column-headers.md @@ -0,0 +1,476 @@ +--- +layout: post +title: Headers in ##Platform_Name## Grid Component +description: Learn here all about Headers in Syncfusion ##Platform_Name## Grid component of Syncfusion Essential JS 2 and more. +platform: ej2-asp-core-mvc +control: Headers +publishingplatform: ##Platform_Name## +documentation: ug +--- + + +# Headers in ASP.NET Core Grid component + +The Syncfusion ASP.NET Core Grid component provides a comprehensive set of options to customize and manage headers efficiently. Headers play a crucial role in organizing and presenting data effectively in the grid. + +## Header text + +The `headerText` feature proves particularly beneficial when there is a need for more meaningful and descriptive column headers in the Syncfusion ASP.NET Core Grid component. + +By default, the header text of a column in Grid is displayed from the column's `field` value. However, you can easily override the default header title and provide a custom header text for the column using the `headerText` property. + +To enable the `headerText` property, you simply need to define it in the **e-grid-column** element. The following example demonstrates how to enable header text for a Grid column. + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/headertext/tagHelper %} +{% endhighlight %} +{% highlight c# tabtitle="Headertext.cs" %} +{% include code-snippet/grid/columns/headertext/headertext.cs %} +{% endhighlight %} +{% endtabs %} + +![Header text](../../images/columns/Column-headertext.png) + +> * If both the `field` and `headerText` are not defined in the column, the column renders with **empty** header text. +> * The `headerText` property is optional, and if it is not defined, then the corresponding column's field value is set as header text for that column. +> * You can also use the `headerTemplate` property to apply custom HTML content to the header cell. + +## Header template + +The header template feature in the Syncfusion ASP.NET Core Grid component allows you to create custom header layouts and content, providing enhanced functionality such as sorting or filtering. + +To implement a header template, set the `headerTemplate` property within a specific column definition. This allows you to render custom HTML elements or ASP.NET Core components to the header. + +The following example demonstrate, the custom element is rendered for both **CustomerID**,**Freight** and **OrderDate** column headers. + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/headertemplate/tagHelper %} +{% endhighlight %} +{% highlight c# tabtitle="Headertemplate.cs" %} +{% include code-snippet/grid/columns/headertemplate/headertemplate.cs %} +{% endhighlight %} +{% endtabs %} + +![Header template](../../images/columns/Column-headertext-headerTemplate.png) + +>* The `headerTemplate` property is only applicable to Grid columns that have a header element. +>* You can use any HTML or ASP.NET Core component in the header template to add additional functionality to the header element. + +## Stacked header + +In Grid, you can group multiple levels of column headers by stacking the Grid columns. This feature allows you to organize the Grid columns in a more structured and understandable way. This can be achieved by setting the [columns->columns](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_Columns) property. Within this property, you can define an array of column objects to group together as sub-headers under a main header. You can define the `headerText` property of each sub-header column to set the text for that sub-header. + +You can customize the appearance of the stacked header elements by using the `headerTemplate` property. This allows you to render custom HTML elements or ASP.NET Core components to the header. + +Here's an example of how to use stacked headers with a custom `headerTemplate` in Syncfusion Grid. + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/headertext-stacked/tagHelper %} +{% endhighlight %} +{% highlight c# tabtitle="Stackedheader.cs" %} +{% include code-snippet/grid/columns/headertext-stacked/stackedHeader.cs %} +{% endhighlight %} +{% endtabs %} + +![Stacked header](../../images/columns/Column-headertext-stacked.png) + +## Align the text of header text + +You can horizontally align the text in column headers of the Grid component using the `headerTextAlign` property. By default, the text is aligned to the left, but you can change the alignment by setting the value of the `headerTextAlign` property to one of the following options: + +* **Left**: Aligns the text to the left (default). +* **Center**: Aligns the text to the center. +* **Right**: Aligns the text to the right. +* **Justify**: Header text is justified. + +The following example demonstrates how to dynamically change the alignment of the header text based on DropDown change: + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/headertext-textalign/tagHelper %} +{% endhighlight %} +{% highlight c# tabtitle="Headertext.cs" %} +{% include code-snippet/grid/columns/headertext-textalign/headertext.cs %} +{% endhighlight %} +{% endtabs %} + +![Align the text of header text](../../images/columns/Column-headertext-change-alignment.gif) + +>* The `headerTextAlign` property only changes the alignment of the text in the column header, and not the content of the column. If you want to align both the column header and content, you can use the [textAlign](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.TextAlign.html) property. +>* You can also use the `headerTextAlign` property with the stacked header feature in Syncfusion Grid. The property will align the header text in the sub-headers as well. + +## Autowrap the header text + +The autowrap allows the cell content of the grid to wrap to the next line when it exceeds the boundary of the specified cell width. The cell content wrapping works based on the position of white space between words. To support the Autowrap functionality in Syncfusion Grid, you should set the appropriate [width](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_Width) for the columns. The column width defines the maximum width of a column and helps to wrap the content automatically. + +To enable autowrap, set the `allowTextWrap` property to **true**. You can also configure the auto wrap mode by setting the [textWrapSettings.wrapMode](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridTextWrapSettings.html#Syncfusion_EJ2_Grids_GridTextWrapSettings_WrapMode) property. + +Grid provides the below three options for configuring: + +* **Both**: This is the default value for wrapMode. With this option, both the grid header text and content is wrapped. +* **Header**: With this option, only the grid header text is wrapped. +* **Content**: With this option, only the grid content is wrapped. + +>* If a column width is not specified, then the Autowrap of columns will be adjusted with respect to the grid's width. +>* If a column's header text contains no white space, the text may not be wrapped. +>* If the content of a cell contains HTML tags, the Autowrap functionality may not work as expected. In such cases, you can use the `headerTemplate` and `template` properties of the column to customize the appearance of the header and cell content. + +The following example demonstrates how to dynamically change the auto-wrap of the header text based on DropDown change. + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/headertext-autowrap/tagHelper %} +{% endhighlight %} +{% highlight c# tabtitle="Headertext.cs" %} +{% include code-snippet/grid/columns/headertext-autowrap/headertext.cs %} +{% endhighlight %} +{% endtabs %} + +![Autowrap the header text](../../images/columns/Column-headertext-wrap-mode.png) + + +## Change the height of header + +Changing the height of the header can be useful in cases where the default height is not sufficient to display the header content cell. For example, if you have a header with a lot of text or if you want to add an image to the header, you may need to increase the height of the header to accommodate the content.This can be easily achieved by changing the height of the header using CSS or by dynamically adjusting the height using a methods. + +**Using css** + +You can use CSS to override the default height of the **.e-grid .e-headercell** class to change the height of the header. Here is an example code snippet: + +```css +.e-grid .e-headercell { + height: 130px; +} +``` + +**Using methods** + +To change the height of the header dynamically, you can use the `getHeaderContent` method to get the header content element of the Syncfusion Grid. Then, you can use the **querySelectorAll** method to get all the header cell elements with the class **e-headercell**. Finally, you can loop through each header cell element and set its style property to adjust the height. + +The following example demonstrates how to dynamically change the height of the header based on a Button `click` event. + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/headertext-change-height/tagHelper %} +{% endhighlight %} +{% highlight c# tabtitle="Headertext.cs" %} +{% include code-snippet/grid/columns/headertext-change-height/headertext.cs %} +{% endhighlight %} +{% endtabs %} + +![Change the height of header](../../images/columns/Column-headertext-change-height.gif) + +>* You can also use the `getHeaderTable` method to get the table element of the header, and then adjust the height. +>* You cannot change the height of row below the default height of 42px using the **e-columnheader** class. + +## Change header text dynamically + +The Syncfusion Grid component provides a way to modify the header text of a corresponding column in real-time based on events or other events. This feature can be useful in various scenarios, such as displaying a custom header text for a specific column or updating the header text dynamically based on input. By allowing for dynamic changes to the header text, the Grid provides a more flexible and customizable experience. + +**Using Event** + +To modify the header text of a corresponding column dynamically, you can use the [headerCellInfo](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_HeaderCellInfo) event provided by the Syncfusion Grid. This event is triggered for each header cell element rendered in the Grid. + +When the `HeaderCellInfo` event is triggered, it provides a **HeaderCellInfoEventArgs** object as a parameter. This object contains the following properties: + +* **cell**: Defines the header cell that is being modified. +* **node**: Defines the DOM element of the header cell that is being modified. + +You can use these properties to access and modify the header text of the corresponding column. Once the header text is modified, you can refresh the Grid to reflect the changes by calling the `refreshHeader` method of the Grid. + +**Using method** + +The Grid component provides several methods that allow you to change the column header text dynamically. Here are some of the methods you can use: + +1. `getColumnByField`: This method takes a field name as a parameter and returns the entire column object that corresponds to that field name, including properties such as headerText, width, and alignment. You can use this method to modify any aspect of the column. + +2. `getColumnHeaderByField`: Retrieves the header element of a column based on its field name. You can modify the **textContent** property of the header element to change the header text. This method does not return a reference to the column object itself, only to the header element. + +3. `getColumnIndexByField`: Retrieves the index of a column based on its field name. You can then use the `getColumnByIndex` method to retrieve the column object and modify its `headerText` property to change the header text. + +4. `getColumnByUid`: Retrieves the column object based on its unique identifier (UID). You can modify the `headerText` property of the column object to change the header text. + +5. `getColumnHeaderByIndex`: Retrieves the header element of a column based on its zero-based index. You can modify the **textContent** property of the header element to change the header text. This method does not return a reference to the column object itself, only to the header element. + +6. `getColumnIndexByUid`: Retrieves the index of a column based on its unique identifier (UID). You can then use the `getColumnByIndex` method to retrieve the column object and modify its `headerText` property to change the header text. + +7. `getColumnHeaderByUid`: Retrieves the header element of a column based on its unique identifier (UID). You can modify the **textContent** property of the header element to change the header text. This method does not return a reference to the column object itself, only to the header element.If you only have an `template` for the column header, and the column itself is not defined with a `field` , then you can use the `getColumnHeaderByUid` method to get a reference to the header element and modify its text content to change the header text. + +>* When you change the header text dynamically, you need to **refresh** the Grid to reflect the changes by calling the `refreshHeader` method. +>* The UID is automatically generated by the Grid component and may change whenever the grid is refreshed or updated. + +Here is an example of how to change the header text of a column using the `getColumnByField` method: + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/headertext-change/tagHelper %} +{% endhighlight %} +{% highlight c# tabtitle="Columntext.cs" %} +{% include code-snippet/grid/columns/headertext-change/columntext.cs %} +{% endhighlight %} +{% endtabs %} + +![Change header text dynamically](../../images/columns/Column-headertext-change.png) + +**Changing the header text of all columns** + +If you want to change the header text of all columns in the grid, you can loop through the Columns collection of the grid and set the `headerText` property for each column. Here is an example: + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/headertext-change-all/tagHelper %} +{% endhighlight %} +{% highlight c# tabtitle="Columntext.cs" %} +{% include code-snippet/grid/columns/headertext-change-all/columntext.cs %} +{% endhighlight %} +{% endtabs %} + +![Changing the header text of all columns](../../images/columns/Column-headertext-change-all.gif) + +## Change the orientation of header text + +By default, the text in the column headers of the Syncfusion Grid control is oriented horizontally. However, in some cases, you may want to change the orientation of the header text to vertical, diagonal, or at a custom angle. This can be achieved by adding a custom CSS class to the column header cell using the `customAttributes` property of the Grid columns. + +Follow the below steps to change the orientation of the header text in Grid: + +**Step 1**: **Create a CSS class with orientation style for grid header cell** + +To `rotate` the header text, you can create a CSS class with the `transform` property that rotates the header text 90 degrees. This class will be added to the header cell using the `customAttributes` property. + +```css +.orientationcss .e-headercelldiv { + transform: rotate(90deg); +} +``` + +**Step 2**: **Add the custom CSS class to the grid column** + +Once you have created the CSS class, you can add it to the particular column by using the `customAttributes` property. This property allows you to add any custom attribute to the grid column. + +For example, to add the orientationcss class to the Freight column, you can use the following code: + +```typescript + +``` + +**Step 3**: **Resize the header cell height** + +After adding the custom CSS class to a column, you need to resize the header cell height so that the rotated header text is fully visible. You can do this by using the following code: + +```typescript + + function setHeaderHeight(args) { + var textWidth = document.querySelector(".orientationcss > div").scrollWidth; // obtain the width of the headerText content. + var headerCell = document.querySelectorAll(".e-headercell"); + for (var i = 0; i < headerCell.length; i++) { + headerCell.item(i).style.height = textWidth + 'px'; // assign the obtained textWidth as the height of the headerCell. + } + } + +``` + +The following example demonstrates how to change the orientation of the **Freight** column header text to 90 degrees: + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/headertext-orientation/tagHelper %} +{% endhighlight %} +{% highlight c# tabtitle="Headertext.cs" %} +{% include code-snippet/grid/columns/headertext-orientation/headertext.cs %} +{% endhighlight %} +{% endtabs %} + +![Change the orientation of header text](../../images/columns/Column-headertext-orientation.png) + + +## Custom tooltip for header + +Custom tooltips for headers provide additional information when hovering over a column header in the Syncfusion Grid. This can be useful in situations where there is not enough space to display all of the information related to a column, or when there is additional context that may be helpful. + +To enable custom tooltips for headers, you can use the `BeforeRender` event of the Grid component. This event is triggered for each header cell before it is rendered, allowing you to add a custom tooltip to the header cell using `tooltip` component. + +Here's an example of how to use the `BeforeRender` event to add a custom tooltip to a header cell: + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/headertext-tooltip/tagHelper %} +{% endhighlight %} +{% highlight c# tabtitle="Headertext.cs" %} +{% include code-snippet/grid/columns/headertext-tooltip/headertext.cs %} +{% endhighlight %} +{% endtabs %} + +![Custom tooltip for header](../../images/columns/Column-headertext-tooltip.png) + +> * The [headerCellInfo](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_HeaderCellInfo) event can also be used to customize the header tooltip. This event is triggered for each header cell after it is rendered. + +## Customize header text styles + +Customizing the grid header styles allows you to modify the appearance of the column header in the Grid control to meet your design requirements. You can customize the font, background color, and other styles of the header cells. To customize the header styles in the grid, you can use CSS, properties, methods, or event support provided by the Syncfusion ASP.NET Core Grid component. + +### Using CSS + +You can apply styles to the header cells using CSS selectors. The Grid provides a class name for each header cell element, which you can use to apply styles to that specific header cell. The **.e-headercell** class can be used to change the background color and text color of the column header. + +```CSS + .e-grid .e-headercell { + background-color: #a2d6f4; + color:rgb(3, 2, 2); + } +``` +Here's an example that demonstrates how to customize the appearance of a column header in the Grid using **className**. + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/headertext-using-css/tagHelper %} +{% endhighlight %} +{% highlight c# tabtitle="Headertext.cs" %} +{% include code-snippet/grid/columns/headertext-using-css/headertext.cs %} +{% endhighlight %} +{% endtabs %} + +![Display HTML content](../../images/columns/Column-headertext-using-css.png) + +### Using property + +You can customize the appearance of the column headers in Grid using the `customAttributes` property. The `customAttributes` property takes an object with the name-value pair to customize the CSS properties for grid header cells. You can also set multiple CSS properties to the custom class using the `customAttributes` property. + +To customize the header of a column, you can follow the steps below: + +Step 1: Define a CSS class that specifies the styles you want to apply to the header cell of the column. For example, to change the background color and text color of the header cell, define a CSS class like this: + + ```CSS + .e-grid .e-headercell.customcss { + background-color: rgb(43, 205, 226); + color: black; + } + + ``` + +Step 2: Set the **customAttributes** property of the desired column to an object that contains the CSS class **customcss**. This CSS class will be applied to the header cell of the specified column in the Grid. + + ```ts + + ``` + +The following example demonstrates how to customize the appearance of the **OrderID** and **OrderDate** columns using custom attributes. + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/headertext-using-property/tagHelper %} +{% endhighlight %} +{% highlight c# tabtitle="Headertext.cs" %} +{% include code-snippet/grid/columns/headertext-using-property/headertext.cs %} +{% endhighlight %} +{% endtabs %} + +![Using property](../../images/columns/Column-headertext-using-property.png) + +### Using method + +The Syncfusion Grid provides methods to customize the appearance of the grid columns header. + +1. `getColumnHeaderByIndex`: The method is used to customize the appearance of a specific column header in the grid by specifying the index of the column for which you want to customize the header. + +2. `getColumnHeaderByField`: This method is used to retrieve the header element of a specific column by its field name. You can use the retrieved element to customize the appearance of the header element. +3. `getColumnHeaderByUid`: This method is used to retrieve the header element of a specific column by its unique ID. You can use the retrieved element to customize the appearance of the header element. + + 4. `getColumnIndexByField`:This method is used to retrieve the index of a specific column by its field name. You can use the retrieved index to access the header element and customize its appearance. + + 5. `getColumnIndexByUid`: This method is used to retrieve the index of a specific column by its unique ID. You can use the retrieved index to access the header element and customize its appearance. + +Here's an example of how to use these methods to change the style of a specific column header: + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/headertext-using-method/tagHelper %} +{% endhighlight %} +{% highlight c# tabtitle="Headertext.cs" %} +{% include code-snippet/grid/columns/headertext-using-method/headertext.cs %} +{% endhighlight %} +{% endtabs %} + +![Using method](../../images/columns/Column-headertext-using-method.png) + +>* The UID is automatically generated by the Grid component and may change whenever the grid is refreshed or updated. + +### Using event + +To customize the appearance of the grid header, you can handle the [headerCellInfo](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_HeaderCellInfo) event of the grid. This event is triggered when each header cell is rendered in the grid, and provides an object that contains information about the header cell. You can use this object to modify the styles of the header column. + +The following example demonstrates how to add a `headerCellInfo` event handler to the grid. In the event handler, checked whether the current header column is **Order Date** field and then applied the appropriate CSS class to the cell based on its value. + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/headertext-using-event/tagHelper %} +{% endhighlight %} +{% highlight c# tabtitle="Headertext.cs" %} +{% include code-snippet/grid/columns/headertext-using-event/headertext.cs %} +{% endhighlight %} +{% endtabs %} + +![Using event](../../images/columns/Column-headertext-using-event.png) + +## How to refresh header + +The refresh header feature in the Syncfusion ASP.NET Core Grid allows you to update the header section of the grid whenever changes are made to the grid's columns. This feature is useful when you want to reflect changes in the header immediately, such as modifying the column header text, width, or alignment. + +To use the refresh header feature, you can call the `refreshHeader` method of the Grid component. This method updates the grid header with the latest changes made to the columns. + +The following example demonstrates how to use the `refreshHeader` method to update the grid header: + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/headertext-refresh/tagHelper %} +{% endhighlight %} +{% highlight c# tabtitle="Headertext.cs" %} +{% include code-snippet/grid/columns/headertext-refresh/headertext.cs %} +{% endhighlight %} +{% endtabs %} + +![How to refresh header](../../images/columns/Column-headertext-refresh-header.png) + +>* The `refreshHeader` method updates only the grid header and not the entire grid. +>* If you want to refresh the entire grid, you can use the `refresh` method instead. + +## How to get header element + +To get the header element in a Syncfusion Grid, you can use one of the following methods: + +1. `getHeaderContent`: This method returns the header div element of the Grid. You can use this method to access the entire header content of the Grid. + + ```ts + var grid = document.getElementById("Grid").ej2_instances[0] + const headerTableElement=grid.getHeaderContent(); + ``` +2. `getHeaderTable`: This method returns the header table element of the Grid. You can use this method to access only the header table of the Grid. + + ```ts + var grid = document.getElementById("Grid").ej2_instances[0] + const headerTableElement = grid.getHeaderTable(); + ``` + +3. `getColumnHeaderByUid`: This method returns the column header element by its unique identifier. + + ```ts + var grid = document.getElementById("Grid").ej2_instances[0] + const columnHeaderElement = grid.getColumnHeaderByUid("e-grid2"); + ``` + +4. `getColumnHeaderByIndex`: This method returns the column header element by its index. + + ```ts + var grid = document.getElementById("Grid").ej2_instances[0] + const columnHeaderElement = grid.getColumnHeaderByIndex(0); + ``` +5. `getColumnHeaderByField`: This method returns the column header element by its field name. + + ```ts + var grid = document.getElementById("Grid").ej2_instances[0] + const columnHeaderElement = grid.getColumnHeaderByField("OrderID"); + ``` + +>* The UID is automatically generated by the Grid component and may change whenever the grid is refreshed or updated. \ No newline at end of file diff --git a/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/columns/column-menu.md b/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/columns/column-menu.md index 6a4ca1aefc..c8ef879a81 100644 --- a/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/columns/column-menu.md +++ b/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/columns/column-menu.md @@ -8,24 +8,24 @@ publishingplatform: ##Platform_Name## documentation: ug --- -# Column Menu +# Column menu in ASP.NET Core Grid component -The column menu has options to integrate features like sorting, grouping, filtering, column chooser, and autofit. It will show a menu with the integrated feature when users click on multiple icon of the column. To enable column menu, you need to define the [`showColumnMenu`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html#Syncfusion_EJ2_Grids_GridColumn_ShowColumnMenu) property as true. +The column menu in the Syncfusion ASP.NET Core Grid component provides options to enable features such as sorting, grouping, filtering, column chooser, and autofit. When users click on the column header's menu icon, a menu will be displayed with these integrated features. To enable the column menu, you need to set the [showColumnMenu](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ShowColumnMenu) property to **true** in the Grid configuration. -The default items are displayed in following table. +To use the column menu, inject the **ColumnMenu** in the **provide** section. -| Item | Description | -|-----|-----| -| `SortAscending` | Sort the current column in ascending order. | -| `SortDescending` | Sort the current column in descending order. | -| `Group` | Group the current column. | -| `Ungroup` | Ungroup the current column. | -| `AutoFit` | Auto fit the current column. | -| `AutoFitAll` | Auto fit all columns. | -| `ColumnChooser` | Choose the column visibility. | -| `Filter` | Show the filter option as given in `FilterSettings.Type` | +The default column menu items are displayed in following table. -{% if page.publishingplatform == "aspnet-core" %} +| Item | Description | +| ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------- | +| **SortAscending** | Sort the current column in ascending order. | +| **SortDescending** | Sort the current column in descending order. | +| **Group** | Group the current column. | +| **Ungroup** | Ungroup the current column. | +| **AutoFit** | Autofit the current column. | +| **AutoFitAll** | Autofit all columns. | +| **ColumnChooser** | Choose the column visibility. | +| **Filter** | Show the filter option as given in [filterSettings.type](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridFilterSettings.html#Syncfusion_EJ2_Grids_GridFilterSettings_Type) | {% tabs %} {% highlight cshtml tabtitle="CSHTML" %} @@ -36,151 +36,108 @@ The default items are displayed in following table. {% endhighlight %} {% endtabs %} -{% elsif page.publishingplatform == "aspnet-mvc" %} - -{% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/columnmenu/razor %} -{% endhighlight %} -{% highlight c# tabtitle="Columnmenu.cs" %} -{% include code-snippet/grid/columns/columnmenu/columnmenu.cs %} -{% endhighlight %} -{% endtabs %} -{% endif %} +![Column menu](../../images/column-menu/Column-menu.png) +> You can disable column menu for a particular column by defining the `columns.showColumnMenu` as **false**. +> You can customize the default items by defining the [columnMenuItems](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ColumnMenuItems) with required items. -N> You can disable column menu for a particular column by defining the [`showColumnMenu`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html#Syncfusion_EJ2_Grids_GridColumn_ShowColumnMenu) property of **e-grid-column** as false. -
You can customize the default items by defining the [`columnMenuItems`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ColumnMenuItems) with required items. +## Add custom column menu item -## Column menu events - -During the resizing action, the grid component triggers the below two events. +The custom column menu item feature allows you to add additional menu items to the column menu in the Syncfusion Grid. These custom menu items can be defined using the [columnMenuItems](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ColumnMenuItems) property, which accepts a collection of `columnMenuItemModel` objects. You can define the actions for these custom items in the [columnMenuClick](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ColumnMenuClick) event. -1. The [`columnMenuOpen`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ColumnMenuOpen) event triggers before the column menu opens. -2. The [`columnMenuClick`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ColumnMenuClick) event triggers when the user clicks the column menu of the grid. - -{% if page.publishingplatform == "aspnet-core" %} +Consider the following example, which demonstrates how to add a custom column menu item to clear the sorting of the Grid: {% tabs %} {% highlight cshtml tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/columnmenuevents/tagHelper %} -{% endhighlight %} -{% highlight c# tabtitle="Columnmenuevents.cs" %} -{% include code-snippet/grid/columns/columnmenuevents/columnmenuevents.cs %} -{% endhighlight %} -{% endtabs %} - -{% elsif page.publishingplatform == "aspnet-mvc" %} - -{% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/columnmenuevents/razor %} +{% include code-snippet/grid/columns/customcolumnmenu/tagHelper %} {% endhighlight %} -{% highlight c# tabtitle="Columnmenuevents.cs" %} -{% include code-snippet/grid/columns/columnmenuevents/columnmenuevents.cs %} +{% highlight c# tabtitle="Columnmenu.cs" %} +{% include code-snippet/grid/columns/customcolumnmenu/columnmenu.cs %} {% endhighlight %} {% endtabs %} -{% endif %} - - -## Custom column menu item +![custom menu](../../images/column-menu/Column-menu-custom.gif) -Custom column menu items can be added by defining the [`columnMenuItems`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ColumnMenuItems) as collection of the **columnMenuItemModel**. +## Customize menu items for particular columns -Actions for this customized items can be defined in the [`columnMenuClick`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ColumnMenuClick) event. +Sometimes, you have a scenario that to hide an item from column menu for particular columns. In that case, you need to define the `columnMenuOpenEventArgs.hide` as **true** in the [columnMenuOpen](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ColumnMenuOpen) event. -{% if page.publishingplatform == "aspnet-core" %} +The following sample, **Filter** item was hidden in column menu when opens for the **OrderID** column. {% tabs %} {% highlight cshtml tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/customcolumnmenu/tagHelper %} -{% endhighlight %} -{% highlight c# tabtitle="Customcolumnmenu.cs" %} -{% include code-snippet/grid/columns/customcolumnmenu/customcolumnmenu.cs %} -{% endhighlight %} -{% endtabs %} - -{% elsif page.publishingplatform == "aspnet-mvc" %} - -{% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/customcolumnmenu/razor %} +{% include code-snippet/grid/columns/customizecolumnmenu/tagHelper %} {% endhighlight %} -{% highlight c# tabtitle="Customcolumnmenu.cs" %} -{% include code-snippet/grid/columns/customcolumnmenu/customcolumnmenu.cs %} +{% highlight c# tabtitle="Columnmenu.cs" %} +{% include code-snippet/grid/columns/customizecolumnmenu/columnmenu.cs %} {% endhighlight %} {% endtabs %} -{% endif %} +![Customize menu items for particular columns](../../images/column-menu/Column-menu-particular.png) +## Render nested column menu -## Customize menu items for particular columns - -Sometimes, you have a scenario that to hide an item from column menu for particular columns. In that case, you need to define the [`ColumnMenuOpenEventArgs.Hide`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ColumnMenuOpen) as true in the [`columnMenuOpen`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ColumnMenuOpen) event. +The nested column menu feature provides an extended menu option in the grid column headers, allows you to access additional actions and options related to the columns. -The following sample, **Filter** item was hidden in column menu when opens for the **OrderID** column. +To enable the nested column menu feature, you need to define the [columnMenuItems](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ColumnMenuItems) property in your component. The `columnMenuItems` property is an array that contains the items for the column menu. Each item can be a string representing a built-in menu item or an object defining a custom menu item. -{% if page.publishingplatform == "aspnet-core" %} +Here is an example of how to configure the `columnMenuItems` property to include a nested menu: {% tabs %} {% highlight cshtml tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/customizecolumnmenu/tagHelper %} -{% endhighlight %} -{% highlight c# tabtitle="Customizecolumnmenu.cs" %} -{% include code-snippet/grid/columns/customizecolumnmenu/customizecolumnmenu.cs %} -{% endhighlight %} -{% endtabs %} - -{% elsif page.publishingplatform == "aspnet-mvc" %} - -{% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/customizecolumnmenu/razor %} +{% include code-snippet/grid/columns/columnmenu-stacked/tagHelper %} {% endhighlight %} -{% highlight c# tabtitle="Customizecolumnmenu.cs" %} -{% include code-snippet/grid/columns/customizecolumnmenu/customizecolumnmenu.cs %} +{% highlight c# tabtitle="Columnmenu.cs" %} +{% include code-snippet/grid/columns/columnmenu-stacked/columnmenu.cs %} {% endhighlight %} {% endtabs %} -{% endif %} - +![Render nested column menu](../../images/column-menu/Column-menu-stacked.png) ## Customize the icon of column menu -You can customize the column menu icon by overriding the default grid class **.e-icons.e-columnmenu** with a custom property **content** as mentioned below, +To customize the column menu icon, you need to override the default grid class **.e-icons.e-columnmenu** with a custom CSS property called **content**. By specifying a Unicode character or an icon font's CSS class, you can change the icon displayed in the column menu. -```css +To customize the column menu icon, follow the below step: -.e-grid .e-columnheader .e-icons.e-columnmenu::before { - content: "\e969"; -} +1.Add the necessary CSS code to override the default grid class: +```css + .e-grid .e-columnheader .e-icons.e-columnmenu::before { + content: "\e799"; + } ``` -In the below sample, grid is rendered with a customized column menu icon. +Here is an example that demonstrates how to customize the column menu icon in the Syncfusion Grid: -{% if page.publishingplatform == "aspnet-core" %} {% tabs %} {% highlight cshtml tabtitle="CSHTML" %} -{% include code-snippet/grid/how-to/custom-column-menu-icon/tagHelper %} +{% include code-snippet/grid/columns/custom-column-menu-icon/tagHelper %} {% endhighlight %} -{% highlight c# tabtitle="Column-icon.cs" %} -{% include code-snippet/grid/how-to/custom-column-menu-icon/column-icon.cs %} +{% highlight c# tabtitle="Columnmenu.cs" %} +{% include code-snippet/grid/columns/custom-column-menu-icon/columnmenu.cs %} {% endhighlight %} {% endtabs %} -{% elsif page.publishingplatform == "aspnet-mvc" %} +![Customize the icon of column menu](../../images/column-menu/column-menu-icon.png) + +## Column menu events + +The column menu in Syncfusion ASP.NET Core Grid provides a set of events that allow customization of behavior and performing actions when the column menu is opened or clicked. The below events are helpful for adding additional functionality or implementing specific actions based on user interactions with the column menu. + +1.The [columnMenuOpen](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ColumnMenuOpen) event triggers before the column menu opens. + +2.The [columnMenuClick](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ColumnMenuClick) event triggers when the user clicks the column menu of the grid. {% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/grid/how-to/custom-column-menu-icon/razor %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/columnmenuevents/tagHelper %} {% endhighlight %} -{% highlight c# tabtitle="Column-icon.cs" %} -{% include code-snippet/grid/how-to/custom-column-menu-icon/column-icon.cs %} +{% highlight c# tabtitle="Columnmenu.cs" %} +{% include code-snippet/grid/columns/columnmenuevents/columnmenu.cs %} {% endhighlight %} {% endtabs %} -{% endif %} +![Column menu events](../../images/column-menu/column-menu-events.gif) \ No newline at end of file diff --git a/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/columns/column-rendering.md b/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/columns/column-rendering.md new file mode 100644 index 0000000000..ec443d3fd2 --- /dev/null +++ b/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/columns/column-rendering.md @@ -0,0 +1,218 @@ +--- +layout: post +title: Column Rendering in ##Platform_Name## Grid Component +description: Learn here all about Column Rendering in Syncfusion ##Platform_Name## Grid component of Syncfusion Essential JS 2 and more. +platform: ej2-asp-core-mvc +control: Column Rendering +publishingplatform: ##Platform_Name## +documentation: ug +--- + +# Column rendering in ASP.NET Core Grid component + +In Syncfusion ASP.NET Core Grid, column rendering provides you with the ability to finely control how data is presented. This allows you to manually define columns, automatically generate them, and dynamically customize data presentation. With column rendering, you can ensure that your data is displayed exactly as needed, offering a wide range of possibilities for organizing and showcasing information within the grid. + +The column definitions are used as the DataSource schema in the grid. The grid operations such as sorting, filtering and grouping etc. are performed based on column definitions. The `field` property of grid column is necessary to map the datasource values in the grid columns. + +> 1. If the column `field` is not specified in the [dataSource](https://help.syncfusion.com/cr/aspnetcore-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_DataSource), column values will be empty. +> 2. If the `field` name contains **dot** operator, it is considered as complex binding. +> 3. It is must to define the `field` property for a Template column, to perform CRUD or data Operations such as filtering, searching etc. + +## Define columns manually + +To define columns manually in grid, you can use the `e-grid-columns` element to define the columns and represent each column with its respective properties such as `field`, `headerText`, `type`, and [width](https://help.syncfusion.com/cr/aspnetcore-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_Width) set accordingly. This allows you to customize the column's behavior and appearance based on the requirements. + +Here's an example code snippet that demonstrates how to define columns manually in the Syncfusion ASP.NET Core Grid: + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/column-rendering/tagHelper %} +{% endhighlight %} +{% highlight c# tabtitle="Column-rendering.cs" %} +{% include code-snippet/grid/columns/column-rendering/column-rendering.cs %} +{% endhighlight %} +{% endtabs %} + +![Define columns](../../images/column-rendering/column-render.png) + +## Auto generated columns + +The Grid automatically generates columns when the `columns` declaration is empty or undefined while initializing the grid. All the columns in the **dataSource** are bound as grid columns. + +You can use the following code snippet to enable auto-generated columns in the Syncfusion Grid: + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/auto/tagHelper %} +{% endhighlight %} +{% highlight c# tabtitle="Auto.cs" %} +{% include code-snippet/grid/columns/auto/auto.cs %} +{% endhighlight %} +{% endtabs %} + +>* When the columns are auto-generated, the column `type` is determined from the first record of the [dataSource](https://help.syncfusion.com/cr/aspnetcore-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_DataSource). +>* If you have a large dataset, auto-generating columns can result in performance issues. In this case, it is recommended to specify the columns manually in the columns property during initialization or else use column virtualization feature by setting [enableColumnVirtualization](https://help.syncfusion.com/cr/aspnetcore-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_EnableColumnVirtualization) property value as **true**. + +### Set isPrimaryKey for auto generated columns when editing is enabled + +When editing is enabled in the grid, you may need to set a primary key for auto-generated columns to uniquely identify each row for operations such as updating or deleting data. This can be achieved using the `isPrimaryKey` property of the column object by using the [dataBound](https://help.syncfusion.com/cr/aspnetcore-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_DataBound) event. + +By setting `isPrimaryKey` to **true** for an auto-generated column in the Syncfusion Grid, you can specify it as the primary key column, which uniquely identifies each row when editing is enabled. + +Here is an example code snippet that shows how to set a primary key for an auto-generated column when editing is enabled: + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/auto-primary/tagHelper %} +{% endhighlight %} +{% highlight c# tabtitle="Primary.cs" %} +{% include code-snippet/grid/columns/auto-primary/primary.cs %} +{% endhighlight %} +{% endtabs %} + +If the column `field` name is known, the `getColumnByField` method can be used to retrieve the column object. Then, the `isPrimaryKey` property can be set to **true** for that column, as demonstrated in the code snippet below: + +```typescript +onDataBound: function() { + let grid = document.getElementById('Grid').ej2_instances[0]; + let column= grid.getColumnByField('OrderID'); + column.isPrimaryKey = true; + } +``` + +### Set column options to auto generated columns + +To configure column options such as `type`, `format` and [width](https://help.syncfusion.com/cr/aspnetcore-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_Width) for auto-generated columns in Syncfusion Grid, you can use the [dataBound](https://help.syncfusion.com/cr/aspnetcore-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_DataBound) event of the Grid component. This event is triggered after the data has been bound to the Grid. By handling this event, you can specify the desired column options for the auto-generated columns. + +Here's an example of how you can set column options for auto-generated columns using the `dataBound` event: + +In the below example, `width` is set for **OrderID** column, **date** `type` is set for **OrderDate** column and `format` is set for **Freight** and **OrderDate** column. + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/autocolumnformat/tagHelper %} +{% endhighlight %} +{% highlight c# tabtitle="Autocolumnformat.cs" %} +{% include code-snippet/grid/columns/autocolumnformat/autocolumnformat.cs %} +{% endhighlight %} +{% endtabs %} + +## Dynamic column generation + +The Syncfusion Grid component allows you to dynamically generate columns at runtime, based on the data provided. This feature is useful when you need to display data with varying columns based on user requirements or dynamic data sources. + +### Using valueAccessor property + +Dynamic column generation using value accessor allows you to access and manipulate the display data values in a grid column. By using the `valueAccessor` property of a grid column, you can customize the display value of the column based on the data. + +To use `valueAccessor` property, define the column with the property and provide a function that will return the formatted value. The function receives two arguments: +* **field**: represents the data field of the column. +* **data**: represents the data record for the corresponding row. + +In the provided code, the **currencyFormatter** function takes the Freight value of the data object, appends the Euro symbol to it, and returns the formatted string. The **concatenateFields** function concatenates the ShipCity and ShipRegion values of the data object and returns the combined string. + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/column-render-valueaccessor/tagHelper %} +{% endhighlight %} +{% highlight c# tabtitle="Valueaccessor.cs" %} +{% include code-snippet/grid/columns/column-render-valueaccessor/valueaccessor.cs %} +{% endhighlight %} +{% endtabs %} + +![Using valueAccessor property](../../images/column-rendering/column-render-valueaccessor.png) + +> The `valueAccessor` function can have performance implications if it is used to access a large number of data records or to perform complex data manipulations. To avoid performance issues, you can enable the virtualization feature while using the `valueAccessor` property. This ensures that only the visible rows are rendered, resulting in faster rendering times. + +### Display array type columns + +The Grid component allows you to easily bind an array of objects to a column using the `valueAccessor` property. This property allows customization of how the data is displayed in the column. + +For example, consider a column named **Name** that contains an array of two objects, **FirstName** and **LastName**. The `valueAccessor` property can be used to join these two objects and bind them to the column. + +This will display the concatenated value of **FirstName** and **LastName** in the **Full Name** column of the grid. Here's an example of how this can be achieved: + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/column-render-array/tagHelper %} +{% endhighlight %} +{% highlight c# tabtitle="Arraytypecolumns.cs" %} +{% include code-snippet/grid/columns/column-render-array/arraytypecolumns.cs %} +{% endhighlight %} +{% endtabs %} + +![Display array type columns](../../images/column-rendering/column-render-array.png) + +### Expression column + +You can achieve an expression column in the Grid by using the `valueAccessor` property. The `valueAccessor` property allows you to define a function that calculates the value for the expression column based on the values of other columns. + +In this example, we have a grid with columns **Food Name**, **Protein**, **Fat**, and **Carbohydrate**. We want to add an expression column called **Calories Intake** that calculates the total calories for each row based on the values of **Protein**, **Fat**, and **Carbohydrate** columns. + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/column-render-expression/tagHelper %} +{% endhighlight %} +{% highlight c# tabtitle="Expressioncolumn.cs" %} +{% include code-snippet/grid/columns/column-render-expression/expressioncolumn.cs %} +{% endhighlight %} +{% endtabs %} + +![Expression column](../../images/column-rendering/column-render-expression%20.png) + +### Display serial number + +To display serial number in the grid for every rows, you can use the [rowDataBound](https://help.syncfusion.com/cr/aspnetcore-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_RowDataBound) event. The `rowDataBound` event is triggered for each row in the grid when the data is bound to the grid. + +Within the event handler, the [pagesize](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridPageSettings.html#Syncfusion_EJ2_Grids_GridPageSettings_PageSize) and [currentPage](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridPageSettings.html#Syncfusion_EJ2_Grids_GridPageSettings_CurrentPage) index can be obtained from the grid's [pageSettings](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridPageSettings.html) property. Using these values, the serial number can be calculated based on the page size, current page, and row index. Finally, the calculated serial number can be set as the innerHTML of the corresponding row cell. + +Here is an example code snippet that demonstrates how to display serial numbers in a Syncfusion Grid using `rowDataBound` event: + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/column-render-serial/tagHelper %} +{% endhighlight %} +{% highlight c# tabtitle="Serialnumber.cs" %} +{% include code-snippet/grid/columns/column-render-serial/serialnumber.cs %} +{% endhighlight %} +{% endtabs %} + +![Display serial number](../../images/column-rendering/column-render-serial.png) + +## Complex data binding + +The Syncfusion Grid component allows you to achieve complex data binding by using the dot (.) operator in the `column.field`. This feature is particularly useful when dealing with nested or complex data structures. + +### Using local data + +To enable complex data binding in the Grid component using local data, use the dot (.) operator in the `field` property of the column. Here is an example of how to achieve complex data binding using local data: + +In the below example, we have bound the nested **Employee** object's **FirstName** and **LastName** properties using the dot (.) operator. + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/complexbinding/tagHelper %} +{% endhighlight %} +{% highlight c# tabtitle="Complexbinding.cs" %} +{% include code-snippet/grid/columns/complexbinding/complexbinding.cs %} +{% endhighlight %} +{% endtabs %} + +![Using local data](../../images/column-rendering/local-data.png) + +### Using remote data + +To enable complex data binding in the Grid component using remote data, add the `expand` query to the [query](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_Query) property of the Grid, to eager load the complex data. Here is an example of how to achieve complex data binding using remote data: + +In the below example, we have used the `expand` query to load the nested Employee object's **City** property using the dot (.) operator. + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/column-render-remote/tagHelper %} +{% endhighlight %} +{% highlight c# tabtitle="Remotedata.cs" %} +{% include code-snippet/grid/columns/column-render-remote/remotedata.cs %} +{% endhighlight %} +{% endtabs %} + +![Using remote data](../../images/column-rendering/column-render-remote.png) diff --git a/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/columns/column-reorder.md b/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/columns/column-reorder.md index 85b2621cd5..ed5842c2ae 100644 --- a/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/columns/column-reorder.md +++ b/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/columns/column-reorder.md @@ -8,11 +8,13 @@ publishingplatform: ##Platform_Name## documentation: ug --- -# Reorder +# Column reorder in ASP.NET Core Grid component -Reordering can be done by drag and drop of a particular column header from one index to another index within the grid. To enable reordering, set the [`allowReordering`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_AllowReordering) property to true. +The Syncfusion ASP.NET Core Grid component allows to reorder columns by drag and drop of a particular column header from one index to another index within the grid. -{% if page.publishingplatform == "aspnet-core" %} +To reorder the columns, set the [allowReordering](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_AllowReordering) property to **true** in the grid. + +Here's an example for column reordering in your Grid component: {% tabs %} {% highlight cshtml tabtitle="CSHTML" %} @@ -23,110 +25,115 @@ Reordering can be done by drag and drop of a particular column header from one i {% endhighlight %} {% endtabs %} -{% elsif page.publishingplatform == "aspnet-mvc" %} +![Column reorder](../../images/column-reorder/column-reorder.gif) + +>* You can customize the appearance of the column headers during drag and drop by using the [columnDrag](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ColumnDrag) and [columnDrop](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ColumnDrop) events. +>* When columns are reordered, the position of the corresponding column data will also be changed. As a result, you should ensure that any additional code or logic that relies on the order of the column data is updated accordingly. + +## Prevent reordering for particular column + +By default, all columns in the Syncfusion ASP.NET Core Grid can be reordered by dragging and dropping their headers to another location within the grid. However, there may be certain columns that you do not want to be reordered. In such cases, you can set the `allowReordering` property of that particular column to **false**. Here is an example that demonstrates how to prevent reordering for a specific column: + +In this example, the **ShipName** column is prevented from being reordered by setting the `allowReordering` property to **false**. {% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/reorder/razor %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/reorder-prevent/tagHelper %} {% endhighlight %} {% highlight c# tabtitle="Reorder.cs" %} -{% include code-snippet/grid/columns/reorder/reorder.cs %} +{% include code-snippet/grid/columns/reorder-prevent/reorder.cs %} {% endhighlight %} {% endtabs %} -{% endif %} +![Prevent reordering for particular column](../../images/column-reorder/column-reorder-prevent.gif) + +## Reorder columns externally + +The Syncfusion Grid ASP.NET Core allows you to reorder columns externally, which means that using methods you can programmatically move columns around within the grid, based on their index or target index, or by using their field name. +> When reordering columns externally, you must set the [allowReordering](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_AllowReordering) property of the grid to **true**. -N> You can disable reordering a particular column by setting the [`allowReordering`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html#Syncfusion_EJ2_Grids_GridColumn_AllowReordering) property of **e-grid-column** as false. +### Reorder column based on index -## Reorder single column +You can use the `reorderColumnByIndex` method to reorder columns based on their current index. This method takes two arguments: -Grid have option to reorder Columns either by Interaction or by using the **reorderColumns** method. In the below sample, **Name** column is reordered to last column position by using the method. +* **fromIndex** : Current index of the column to be reordered +* **toIndex** : New index of the column after the reordering -{% if page.publishingplatform == "aspnet-core" %} +Here is an example of how to use the `reorderColumnByIndex` method: + +In this example, we are moving the column at index **1** to index **3**. {% tabs %} {% highlight cshtml tabtitle="CSHTML" %} {% include code-snippet/grid/columns/reordercols/tagHelper %} {% endhighlight %} -{% highlight c# tabtitle="Reordercols.cs" %} -{% include code-snippet/grid/columns/reordercols/reordercols.cs %} +{% highlight c# tabtitle="Reorder.cs" %} +{% include code-snippet/grid/columns/reordercols/reorder.cs %} {% endhighlight %} {% endtabs %} -{% elsif page.publishingplatform == "aspnet-mvc" %} +![Reorder column based on index](../../images/column-reorder/column-reorder-index.gif) + +### Reorder column based on target index + +You can also use the `reorderColumnByTargetIndex` method to reorder single column or multiple columns based on the target index. This method takes two arguments: + +* **fieldName**: Field name of the column to be reordered +* **toIndex**: New index of the column after the reordering + +Here is an example of how to use the `reorderColumnByTargetIndex` method to reorder single column and multiple columns based on target index: {% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/reordercols/razor %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/reordertargetcolumns/tagHelper %} {% endhighlight %} -{% highlight c# tabtitle="Reordercols.cs" %} -{% include code-snippet/grid/columns/reordercols/reordercols.cs %} +{% highlight c# tabtitle="Reorder.cs" %} +{% include code-snippet/grid/columns/reordertargetcolumns/reorder.cs %} {% endhighlight %} {% endtabs %} -{% endif %} +![Reorder column based on target index](../../images/column-reorder/column-reorder-target.gif) +### Reorder column based on field names -## Reorder multiple columns +The `reorderColumns` method of the Grid allows you to reorder single column or list of columns based on their field names. This method takes two arguments: -You can reorder a single column at a time by Interaction. Sometimes we need to reorder multiple columns at the same time, It can be achieved through programmatically by using **reorderColumns** method. +* **fromFName**: The field name of the column you want to move. +* **toFName**: The field name of the column you want to move the column to. -In the below sample, **Ship City** and **Ship Region** column is reordered to last column position. - -{% if page.publishingplatform == "aspnet-core" %} +Here is an example of how to use the `reorderColumns` method to reorder single column and multiple columns based on field names: {% tabs %} {% highlight cshtml tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/reordercolumns/tagHelper %} +{% include code-snippet/grid/columns/reorder-field/tagHelper %} {% endhighlight %} -{% highlight c# tabtitle="Reordercols.cs" %} -{% include code-snippet/grid/columns/reordercolumns/reordercols.cs %} +{% highlight c# tabtitle="Reorder.cs" %} +{% include code-snippet/grid/columns/reorder-field/reorder.cs %} {% endhighlight %} {% endtabs %} -{% elsif page.publishingplatform == "aspnet-mvc" %} - -{% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/reordercolumns/razor %} -{% endhighlight %} -{% highlight c# tabtitle="Reordercols.cs" %} -{% include code-snippet/grid/columns/reordercolumns/reordercols.cs %} -{% endhighlight %} -{% endtabs %} -{% endif %} +![Reorder column based on field names](../../images/column-reorder/column-reorder-field.gif) +## Reorder events +When reordering columns in the Syncfusion ASP.NET Core Grid component, you may want to take some specific action in response to the drag and drop events. To handle these events, you can define event handlers for the following events: -## Reorder events +1.The [columnDragStart](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ColumnDragStart) event triggers when column header element drag (move) starts. -During the reorder action, the grid component triggers the below three events. +2.The [columnDrag](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ColumnDrag) event triggers when column header element is dragged (moved) continuously. -1. The [`columnDragStart`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ColumnDragStart) event triggers when column header element drag (move) starts. -2. The [`columnDrag`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ColumnDrag) event triggers when column header element is dragged (moved) continuously. -3. The [`columnDrop`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ColumnDrop) event triggers when a column header element is dropped on the target column. +3.The [columnDrop](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ColumnDrop) event triggers when a column header element is dropped on the target column. -{% if page.publishingplatform == "aspnet-core" %} +In the following example, we have implemented the `columnDragStart`, `columnDrag`, and `columnDrop` events in the Syncfusion Grid component. {% tabs %} {% highlight cshtml tabtitle="CSHTML" %} {% include code-snippet/grid/columns/reorderevents/tagHelper %} {% endhighlight %} -{% highlight c# tabtitle="Reorderevents.cs" %} -{% include code-snippet/grid/columns/reorderevents/reorderevents.cs %} -{% endhighlight %} -{% endtabs %} - -{% elsif page.publishingplatform == "aspnet-mvc" %} - -{% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/reorderevents/razor %} -{% endhighlight %} -{% highlight c# tabtitle="Reorderevents.cs" %} -{% include code-snippet/grid/columns/reorderevents/reorderevents.cs %} +{% highlight c# tabtitle="Reorder.cs" %} +{% include code-snippet/grid/columns/reorderevents/reorder.cs %} {% endhighlight %} {% endtabs %} -{% endif %} +![Reorder events](../../images/column-reorder/column-reorder-events.gif) \ No newline at end of file diff --git a/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/columns/column-resizing.md b/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/columns/column-resizing.md index 42d38b645d..d48b9fa1cc 100644 --- a/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/columns/column-resizing.md +++ b/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/columns/column-resizing.md @@ -8,11 +8,11 @@ publishingplatform: ##Platform_Name## documentation: ug --- -# Column Resizing in ASP.Net Core Grid component +# Column resizing in ##Platform_Name## Grid component -Column width can be resized by clicking and dragging the right edge of the column header. While dragging, the width of the respective column will be resized immediately. Each column can be auto resized by double-clicking the right edge of the column header to fit the width of that column based on the widest cell content. To enable column resize, set the [`allowResizing`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_AllowResizing) property to true. +Grid component provides an intuitive user interface for resizing columns to fit their content. This feature allows users to easily adjust the width of the columns to improve readability and aesthetics of the data presented. To enable column resizing, set the [allowResizing](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_AllowResizing) property of the grid to **true**. -{% if page.publishingplatform == "aspnet-core" %} +Once column resizing is enabled, columns width can be resized by clicking and dragging at the right edge of the column header. While dragging the column, the width of the respective column will be resized immediately. {% tabs %} {% highlight cshtml tabtitle="CSHTML" %} @@ -23,138 +23,151 @@ Column width can be resized by clicking and dragging the right edge of the colum {% endhighlight %} {% endtabs %} -{% elsif page.publishingplatform == "aspnet-mvc" %} +![Column resizing](../../images/column-resize/column-resize.gif) + +>* You can disable Resizing for a particular column, by specifying `columns.allowResizing` to **false**. +>* In RTL mode, you can click and drag the left edge of header cell to resize the column. +>* The `width` property of the column can be set initially to define the default width of the column. However, when column resizing is enabled, you can override the default width by manually resizing the columns. + +## Restrict the resizing based on minimum and maximum width + +The Grid component allows you to restrict the column width resizing between a minimum and maximum width. This can be useful when you want to ensure that your grid's columns stay within a certain range of sizes. + +To enable this feature, you can define the `columns.minWidth` and `columns.maxWidth` properties of the columns directive for the respective column. + +In the below code, **OrderID**, **Ship Name** and **Ship Country** columns are defined with minimum and maximum width. The **OrderID** column is set to have a minimum width of 100 pixels and a maximum width of 250 pixels. Similarly, the **CustomerID** column is set to have a minimum width of 150 pixels and a maximum width of 300 pixels. The **ShipCountry** column is set to have a minimum width of 120 pixels and a maximum width of 260 pixels. {% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/resize/razor %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/resize-max/tagHelper %} {% endhighlight %} {% highlight c# tabtitle="Resize.cs" %} -{% include code-snippet/grid/columns/resize/resize.cs %} +{% include code-snippet/grid/columns/resize-max/resize.cs %} {% endhighlight %} {% endtabs %} -{% endif %} - - -N> You can disable resizing for a particular column by setting the [`allowResizing`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html#Syncfusion_EJ2_Grids_GridColumn_AllowResizing) property of **e-grid-column** tag helper to false. -
In RTL mode, you can click and drag the left edge of the header cell to resize the column. +![Restrict the resizing based on minimum and maximum width](../../images/column-resize/Colum-resize-max.gif) -## Column resizing using method +>* The `columns.minWidth` and `columns.maxWidth` properties will be considered only when the user resizes the column. When resizing the window, these properties will not be considered. This is because columns cannot be re-rendered when resizing the window. +>* When setting the `minWidth` and `maxWidth` properties, ensure that the values are appropriate for your data and layout requirements. +>* The specified `minWidth` and `maxWidth` values take precedence over any user-initiated resizing attempts that fall outside the defined range. -To resize a column, set width to that particular column and then refresh the grid header by using the **refreshHeader** method. Refer the below code, +## Prevent resizing for particular column -```javascript +The Grid component provides the ability to prevent resizing for a particular column. This can be useful if you want to maintain a consistent column width or prevent users from changing the width of a column. -var grid = document.getElementById('Grid').ej2_instances[0]; //Grid Instance +You can disable resizing for a particular column by setting the `allowResizing` property of the column to **false**. The following example demonstrates, how to disabled resize for **Customer ID** column. -var columns = grid.columns; - -columns[0].width = 150; +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/resize-prevent/tagHelper %} +{% endhighlight %} +{% highlight c# tabtitle="Resize.cs" %} +{% include code-snippet/grid/columns/resize-prevent/resize.cs %} +{% endhighlight %} +{% endtabs %} -grid.refreshHeader(); +> You can also prevent resizing by setting `args.cancel` to **true** in the [resizeStart](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ResizeStart) event. -``` +## Resizing modes -## Min and max width +The Syncfusion Grid component provides a `ResizeSettingsModel` interface for configuring the resizing behavior of grid columns. The interface includes a property named `mode` which is of the type `ResizeMode`. The `ResizeMode` is an enum that determines the available resizing modes for the grid columns. There are two resizing modes available for grid columns in Grid: -Column resize can be restricted between minimum and maximum width by defining the [`minWidth`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html#Syncfusion_EJ2_Grids_GridColumn_MinWidth) and [`maxWidth`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html#Syncfusion_EJ2_Grids_GridColumn_MaxWidth) properties in **e-grid-column** tag helper. +1. `Normal Mode`: This mode does not adjust the columns to fit the remaining space. When the sum of column width is less than the grid's width, empty space will be present to the right of the last column. When the sum of column width is greater than the grid's width, columns will overflow, and a horizontal scrollbar will appear. -In the following sample, minimum and maximum width are defined for **OrderID**, **Ship Name**, and **Ship Country** columns. +2. `Auto Mode`: This mode automatically resizes the columns to fill the remaining space. When the sum of column width is less than the grid's width, the columns will be automatically expanded to fill the empty space. Conversely, when the sum of column width is greater than the grid's width, the columns will be automatically contracted to fit within the available space. -{% if page.publishingplatform == "aspnet-core" %} +The following example demonstrates how to set the [resizeSettings.mode](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridResizeSettings.html#Syncfusion_EJ2_Grids_GridResizeSettings_Mode) property to **Normal** and **Auto** on changing the dropdown value using the [change](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.DropDowns.DropDownList.html#Syncfusion_EJ2_DropDowns_DropDownList_Change) event of the DropDownList component. {% tabs %} {% highlight cshtml tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/min/tagHelper %} +{% include code-snippet/grid/columns/resize-mode/tagHelper %} {% endhighlight %} -{% highlight c# tabtitle="Min.cs" %} -{% include code-snippet/grid/columns/min/min.cs %} +{% highlight c# tabtitle="Resize.cs" %} +{% include code-snippet/grid/columns/resize-mode/resize.cs %} {% endhighlight %} {% endtabs %} -{% elsif page.publishingplatform == "aspnet-mvc" %} +![Reorder events](../../images/column-resize/Colum-resize-mode.gif) + +## Resize stacked header column + +Grid component allows to resize stacked columns by clicking and dragging the right edge of the stacked column header. During the resizing action, the width of the child columns is resized at the same time. You can disable resize for any particular stacked column by setting [allowResizing](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_AllowResizing) as **false** to its columns. + +In this below code, we have disabled resize for **Ship City** column. {% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/min/razor %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/resize-stacked/tagHelper %} {% endhighlight %} -{% highlight c# tabtitle="Min.cs" %} -{% include code-snippet/grid/columns/min/min.cs %} +{% highlight c# tabtitle="Resize.cs" %} +{% include code-snippet/grid/columns/resize-stacked/resize.cs %} {% endhighlight %} {% endtabs %} -{% endif %} +![Reorder events](../../images/column-resize/Colum-resize-stacked.gif) -N> The `maxWidth` and `minWidth` properties will be considered only when the user resizes the column. When resizing the window, these properties will not be considered. This is because columns cannot be re-rendered when resizing the window. +> When the [autoFit](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_AutoFit) property is set to **true**, the Grid will automatically adjust its column width based on the content inside them. In `normal` resize mode, if the `autoFit` property is set to **true**, the Grid will maintain any empty space that is left over after resizing the columns. However, in `auto` resize mode, the Grid will ignore any empty space. -## Resize stacked column +## Touch interaction -Stacked columns can be resized by clicking and dragging the right edge of the stacked column header. While dragging, the width of the respective child columns will be resized at the same time. You can disable resize for any particular stacked column by setting [`allowResizing`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_AllowResizing) property **e-grid-column** as **false** to its columns. +Grid component provides support for touch interactions to enable users to interact with the grid using their mobile devices. Users can resize columns in the grid by tapping and dragging the floating handler, and can also use the Column menu to autofit columns. -In this example, we have disabled resize for **Ship City** column. +**Resizing Columns on Touch Devices** -{% if page.publishingplatform == "aspnet-core" %} +To resize columns on a touch device: -{% tabs %} -{% highlight cshtml tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/stacked/tagHelper %} -{% endhighlight %} -{% highlight c# tabtitle="Stacked.cs" %} -{% include code-snippet/grid/columns/stacked/stacked.cs %} -{% endhighlight %} -{% endtabs %} +1.Tap on the right edge of the header cell of the column that you want to resize. -{% elsif page.publishingplatform == "aspnet-mvc" %} +2.A floating handler will appear over the right border of the column. -{% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/stacked/razor %} -{% endhighlight %} -{% highlight c# tabtitle="Stacked.cs" %} -{% include code-snippet/grid/columns/stacked/stacked.cs %} -{% endhighlight %} -{% endtabs %} -{% endif %} +3.Tap and drag the floating handler to resize the column to the desired width. +The following screenshot represents the column resizing on the touch device. +![Touch Interaction](../../images/column-resizing.jpg) -## Touch interaction +## Resizing column externally -When the right edge of the header cell is tapped, a floating handler will be visible over the right border of the column. To resize the column, tap and drag the floating handler as needed. You can autoFit a column by using the Column menu of the grid. +Grid provides the ability to resize columns using an external button click. This can be achieved by changing the `width` property of the column and refreshing the grid using the `refreshColumns` method in the external button click function. + +The following example demonstrates how to resize the columns in a grid. This is done by using the [change](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.DropDowns.DropDownList.html#Syncfusion_EJ2_DropDowns_DropDownList_Change) event of the DropDownList component by change the `width` property of the selected column. This is accomplished using the `getColumnByField` on external button click. Then, the `refreshColumns` method is called on the grid component to update the displayed columns based on interaction. + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/resize-external/tagHelper %} +{% endhighlight %} +{% highlight c# tabtitle="Resize.cs" %} +{% include code-snippet/grid/columns/resize-external/resize.cs %} +{% endhighlight %} +{% endtabs %} -The following screenshot represents the column resizing in touch device. +![Reorder events](../../images/column-resize/Colum-resize-external.png) -![Touch interaction](../../images/column-resizing.jpg) +> The `refreshColumns` method is used to refresh the grid after the column widths are updated. Column resizing externally is useful when you want to provide a custom interface to the user for resizing columns. ## Resizing events During the resizing action, the grid component triggers the below three events. -1. The [`resizeStart`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ResizeStart) event triggers when column resize starts. -2. The [`resizing`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_Resizing) event triggers when column header element is dragged (moved) continuously. -3. The [`resizeStop`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ResizeStop) event triggers when column resize ends. +1.The [resizeStart](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ResizeStart) event triggers when column resize starts. This event can be used to perform actions when the user begins to resize a column. + +2.The [resizing](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_Resizing) event triggers when column header element is dragged (moved) continuously. This event is useful when you want to perform certain actions during the column resize process. -{% if page.publishingplatform == "aspnet-core" %} +3.The [resizeStop](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ResizeStop) event triggers when column resize ends. This event can be used to perform actions after the column is resized. + +The following is an example of using the resizing events, the `resizeStart` event is used to cancel the resizing of the **OrderID** column. The `resizeStop` event is used to apply custom CSS attributes to the resized column. {% tabs %} {% highlight cshtml tabtitle="CSHTML" %} {% include code-snippet/grid/columns/resizeevents/tagHelper %} {% endhighlight %} -{% highlight c# tabtitle="Resizeevents.cs" %} -{% include code-snippet/grid/columns/resizeevents/resizeevents.cs %} +{% highlight c# tabtitle="Resize.cs" %} +{% include code-snippet/grid/columns/resizeevents/resize.cs %} {% endhighlight %} {% endtabs %} -{% elsif page.publishingplatform == "aspnet-mvc" %} +![Reorder events](../../images/column-resize/Colum-resize-event.gif) -{% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/resizeevents/razor %} -{% endhighlight %} -{% highlight c# tabtitle="Resizeevents.cs" %} -{% include code-snippet/grid/columns/resizeevents/resizeevents.cs %} -{% endhighlight %} -{% endtabs %} -{% endif %} +>The ResizeArgs object passed to the events contains information such as the current column width, new column width, column index, and the original event. The [resizing](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_Resizing) event is triggered multiple times during a single resize operation, so be careful when performing heavy operations in this event. diff --git a/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/columns/columns.md b/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/columns/columns.md index 57851e0be8..8bbee1b14c 100644 --- a/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/columns/columns.md +++ b/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/columns/columns.md @@ -32,35 +32,6 @@ Grid column supports the following types: N> If the [`type`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html#Syncfusion_EJ2_Grids_GridColumn_Type) is not defined, it will be determined from the first record of the **DataSource**.
Incase if the first record of the **DataSource** is null/blank value for a column then it is necessary to define the [`type`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html#Syncfusion_EJ2_Grids_GridColumn_Type) for that column. -## ValueAccessor - -The **valueAccessor** is used to access/manipulate the value of display data. You can achieve custom value formatting by using the valueAccessor. - -{% if page.publishingplatform == "aspnet-core" %} - -{% tabs %} -{% highlight cshtml tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/valueaccessor/tagHelper %} -{% endhighlight %} -{% highlight c# tabtitle="Valueaccessor.cs" %} -{% include code-snippet/grid/columns/valueaccessor/valueaccessor.cs %} -{% endhighlight %} -{% endtabs %} - -{% elsif page.publishingplatform == "aspnet-mvc" %} - -{% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/valueaccessor/razor %} -{% endhighlight %} -{% highlight c# tabtitle="Valueaccessor.cs" %} -{% include code-snippet/grid/columns/valueaccessor/valueaccessor.cs %} -{% endhighlight %} -{% endtabs %} -{% endif %} - - - ## Format To format cell values based on specific culture, use the [`format`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html#Syncfusion_EJ2_Grids_GridColumn_Format) property of **e-grid-column** tag helper . The grid uses **Internalization** library to format **number** and **date** values. diff --git a/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/columns/complex-data-binding.md b/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/columns/complex-data-binding.md deleted file mode 100644 index e7b1c506cb..0000000000 --- a/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/columns/complex-data-binding.md +++ /dev/null @@ -1,64 +0,0 @@ ---- -layout: post -title: Complex Data Binding in ##Platform_Name## Grid Component -description: Learn here all about Complex Data Binding in Syncfusion ##Platform_Name## Grid component of Syncfusion Essential JS 2 and more. -platform: ej2-asp-core-mvc -control: Complex Data Binding -publishingplatform: ##Platform_Name## -documentation: ug ---- - -# Complex Data Binding - -You can achieve complex data binding in the grid by using the dot(.) operator in the [`field`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html#Syncfusion_EJ2_Grids_GridColumn_Field) property of **e-grid-column** tag helper. - -{% if page.publishingplatform == "aspnet-core" %} - -{% tabs %} -{% highlight cshtml tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/complexbinding/tagHelper %} -{% endhighlight %} -{% highlight c# tabtitle="Complexbinding.cs" %} -{% include code-snippet/grid/columns/complexbinding/complexbinding.cs %} -{% endhighlight %} -{% endtabs %} - -{% elsif page.publishingplatform == "aspnet-mvc" %} - -{% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/complexbinding/razor %} -{% endhighlight %} -{% highlight c# tabtitle="Complexbinding.cs" %} -{% include code-snippet/grid/columns/complexbinding/complexbinding.cs %} -{% endhighlight %} -{% endtabs %} -{% endif %} - - - -For OData and ODataV4 adaptors, you need to add [`expand`](https://ej2.syncfusion.com/documentation/api/data/query/#expand) query to the [`query`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_Query) property (of Grid), to eager load the complex data. - -{% if page.publishingplatform == "aspnet-core" %} - -{% tabs %} -{% highlight cshtml tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/query/tagHelper %} -{% endhighlight %} -{% highlight c# tabtitle="Query.cs" %} -{% include code-snippet/grid/columns/query/query.cs %} -{% endhighlight %} -{% endtabs %} - -{% elsif page.publishingplatform == "aspnet-mvc" %} - -{% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/query/razor %} -{% endhighlight %} -{% highlight c# tabtitle="Query.cs" %} -{% include code-snippet/grid/columns/query/query.cs %} -{% endhighlight %} -{% endtabs %} -{% endif %} - diff --git a/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/columns/frozen-column.md b/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/columns/frozen-column.md new file mode 100644 index 0000000000..8de586e73f --- /dev/null +++ b/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/columns/frozen-column.md @@ -0,0 +1,144 @@ +--- +layout: post +title: Column pinning (Frozen) in Syncfusion ##Platform_Name## Grid Component +description: Learn here all about Column pinning (Frozen) in Syncfusion ##Platform_Name## Grid component of Syncfusion Essential JS 2 and more. +platform: ej2-asp-core-mvc +control: Column pinning (Frozen) +publishingplatform: ##Platform_Name## +documentation: ug +--- + +# Column Pinning (Frozen) in ASP.NET Core Grid component + +In the Syncfusion ASP.NET Core Grid component, you have the capability to **freeze** columns, ensuring they remain visible as you scroll through extensive datasets. This functionality significantly improves user experience by keeping critical information constantly within view, even when navigating through large volumes of data. This means that important columns remain fixed in their positions, making it easier to access and reference key data points while working with the grid. + +In the following example, the [frozenColumns](https://help.syncfusion.com/cr/aspnetcore-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_FrozenColumns) property is set to **2**. This configuration freezes the left two columns of the grid, and they will remain fixed in their positions while the rest of the columns grid can be scrolled horizontally. + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/frozen-columns/tagHelper %} +{% endhighlight %} +{% highlight c# tabtitle="Frozen.cs" %} +{% include code-snippet/grid/columns/frozen-columns/frozen.cs %} +{% endhighlight %} +{% endtabs %} + +![Column Pinning](../../images/column-chooser/frozon.png) + +> * Frozen columns should not be set outside the grid view port. +> * Frozen Grid support column virtualization feature, which helps to improve the Grid performance while loading a large dataset. +> * The frozen feature is supported only for the columns that are visible in the current view. +> * You can use both `frozenColumns` property and [frozenRows](https://help.syncfusion.com/cr/aspnetcore-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_FrozenRows) property in the same application. + +## Freeze particular columns + +The Syncfusion ASP.NET Core Grid provides a valuable feature that enables you to freeze specific columns, significantly enhancing data visibility and improving your overall user experience. This functionality allows you to select particular columns and freeze them by positioning them at the leftmost side of the grid, ensuring they remain fixed in place while the remaining grid columns can still be scrolled horizontally. While the `frozenColumns` property freezes columns in the order they are initialized in the grid, you can also use the `isFrozen` property at the column level to freeze a specific column at any desired index on the left side, offering flexibility in managing which columns are frozen. + +To freeze a particular column in the grid, you can utilize the `isFrozen` property of the grid component as **true**. + +The following example demonstrates how to freeze particular column in grid using `isFrozen` property. This is achieved by the [change](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.DropDowns.DropDownList.html#Syncfusion_EJ2_DropDowns_DropDownList_Change) event of the `DropDownList` component. Within the change event, you can modify the `isFrozen` property of the selected column using the `getColumnByField` method. Afterward, you can use the `refreshColumns` method to update the displayed columns based on your interaction. + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/frozen-particular/tagHelper %} +{% endhighlight %} +{% highlight c# tabtitle="Frozen.cs" %} +{% include code-snippet/grid/columns/frozen-particular/frozen.cs %} +{% endhighlight %} +{% endtabs %} + +![Freeze particular columns](../../images/column-chooser/frozon-particular.png) + +## Freeze direction + +In the Syncfusion ASP.NET Core Grid, the "freeze direction" feature serves to reposition frozen columns either to the left, right, or in a fixed position, while still allowing the remaining columns to be horizontally movable. This feature is designed to optimize user experience by ensuring that critical information remains visible even during horizontal scrolling. By default, when you set the `frozenColumns` property of the grid or the `isFrozen` property of individual columns, it results in freezing those columns on the left side of the grid. This helps in keeping important data readily accessible as you navigate through your dataset. + +To achieve this, you can utilize the `column.freeze` property. This property is used to specify the freeze direction for individual columns. The grid will adjust the column positions based on the `column.freeze` value. + +The types of the `column.freeze` directions: + +* **Left**: When you set the `column.freeze` property to **Left**, specific columns will be frozen on the left side of the grid. The remaining columns will be movable. + +* **Right**: When you set the `column.freeze` property to **Right**, certain columns will be frozen on the right side of the grid, while the rest of the columns remain movable. + +* **Fixed**: The Fixed direction locks a column at a fixed position within the grid. This ensures that the column is always visible during horizontal scroll. + +In the following example, the **ShipCountry** column is frozen on the left side, the **CustomerID** column is frozen on the right side and the **Freight** column is frozen on the fixed of the content table. Additionally, you can modify the `column.freeze` property to **Left**, **Right** and **Fixed** based on the selected column by utilizing the [change](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.DropDowns.DropDownList.html#Syncfusion_EJ2_DropDowns_DropDownList_Change) event of the `DropDownList` component. + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/frozen-direction/tagHelper %} +{% endhighlight %} +{% highlight c# tabtitle="Frozen.cs" %} +{% include code-snippet/grid/columns/frozen-direction/frozen.cs %} +{% endhighlight %} +{% endtabs %} + +![Freeze direction](../../images/column-chooser/frozon-direction.png) + +> * Freeze Direction is not compatible with the `isFrozen` and [frozenColumns](https://help.syncfusion.com/cr/aspnetcore-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_FrozenColumns) properties. + +## Change default frozen line color + +You can customize the frozen line borders of frozen columns in the Syncfusion Grid component by applying custom CSS styles to the specific frozen column. This allows you to change the border color of the left frozen columns, right frozen columns, and fixed frozen columns to match your application's design and theme. + +To change default frozen line color, use the following class name and apply the border color based on your requirement. + +For left frozen columns: + +```css +.e-grid .e-leftfreeze.e-freezeleftborder { + border-right-color: rgb(198, 30, 204); +} +``` +For right frozen columns: + +```css +.e-grid .e-rightfreeze.e-freezerightborder { + border-left-color: rgb(19, 228, 243); +} +``` +For fixed frozen columns, you need to specify both left and right border as mentioned below + +```css +.e-grid .e-fixedfreeze.e-freezeleftborder{ + border-left-color: rgb(9, 209, 9); +} + +.e-grid .e-fixedfreeze.e-freezerightborder{ + border-right-color: rgb(10, 224, 10); +} +``` +The following example demonstrates how to change the default frozen line color using CSS. + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/columns/frozen-color/tagHelper %} +{% endhighlight %} +{% highlight c# tabtitle="Frozen.cs" %} +{% include code-snippet/grid/columns/frozen-color/frozen.cs %} +{% endhighlight %} +{% endtabs %} + +![Change default frozen line color](../../images/column-chooser/frozon-color.png) + +## Deprecated methods + +Previous | Current | Explanation + --- | --- | --- +`getMovableRows()` gridInstance.getMovableRows()[0].querySelectorAll('.e-unfreeze') | `getRows()` gridInstance.getRows()[0].querySelectorAll('.e-unfreeze') | The previous architecture used separate tables for left, right, and movable contents, returning only movable rows when calling the method, whereas the current architecture combines them into one table, returning all rows and introduces the `e-unfreeze` class for selecting movable rows +`getFrozenRightRows()` gridInstance.getFrozenRightRows()[0].querySelectorAll('.e-rightfreeze') | `getRows()` gridInstance.getRows()[0].querySelectorAll('.e-rightfreeze') | In the previous architecture, it returned only the table rows from the right freeze table, but in the current architecture, all rows of the entire table are returned, introducing the `e-rightfreeze` class for selecting right freeze rows. +`getMovableRowByIndex()`
`getFrozenRowByIndex()`
`getFrozenRightRowByIndex()` | `getRowByIndex()` gridInstance.getRowByIndex(1).querySelectorAll('.e-unfreeze') | In the previous architecture, separate methods were used to select rows from different table sections, while in the current architecture, the `getMovableRowByIndex()`, `getFrozenRightRowByIndex()`, and `getFrozenRowByIndex()` methods now return the same table row based on the given index. Additionally, class names for table cells (td's) have been separated into `e-leftfreeze`, `e-unfreeze`, and `e-rightfreeze`, making it easier to customize cells within a row. +`getMovableCellFromIndex()`
`getFrozenRightCellFromIndex()` | `getCellFromIndex()` gridInstance.getCellFromIndex(1,1) | In the previous approach, the `getMovableCellFromIndex()` method was used to choose a specific cell within the movable table, and the `getFrozenRightCellFromIndex()` method was utilized to target a particular cell within the right freeze table. However, in the current architecture, you have the flexibility to select a specific cell in either the movable or right freeze table by using both the `getFrozenRightCellFromIndex()` and `getMovableCellFromIndex()` methods. This new method simplifies the process of selecting and retrieving specific cells within these tables, offering more versatility and convenience. +`getMovableDataRows()`
`getFrozenRightDataRows()`
`getFrozenDataRows()` | `getDataRows()` gridInstance.getDataRows()[0].querySelectorAll('.e-unfreeze') | In the previous approach, there were separate methods (`getMovableDataRows()`, `getFrozenRightDataRows()`, and `getFrozenDataRows()`) for obtaining viewport data rows from the freeze, movable, and right tables individually. However, in the new approach, these methods have been enhanced to return the entire viewport data rows for all sections together, simplifying data retrieval. You can now extract specific cells within these rows using selectors such as `e-leftfreeze` for the **left freeze**, `e-unfreeze` for the **movable**, and `e-rightfreeze` for the **right freeze** tables, providing greater flexibility in working with the data. +`getMovableColumnHeaderByIndex()`
`getFrozenRightColumnHeaderByIndex()`
`getFrozenLeftColumnHeaderByIndex()` | `getColumnHeaderByIndex()` gridInstance.getColumnHeaderByIndex(1) | In the previous architecture, the methods selected movable, right freeze, and left freeze headers separately. However, in the new approach, when using the `getMovableColumnHeaderByIndex()`, `getFrozenRightColumnHeaderByIndex()`, and `getFrozenLeftColumnHeaderByIndex()` methods, you will still obtain the same results as in the previous architecture. + +> When a validation message is displayed in the frozen part (Left, Right, Fixed) of the table, scrolling is prevented until the validation message is cleared. + +## Limitations + +While freezing columns in the Syncfusion ASP.NET Core Grid provides enhanced visibility and scrolling capabilities, there are certain limitations to consider. The following features are not supported when using frozen columns: + +* Detail Template +* Hierarchy Grid +* Autofill \ No newline at end of file diff --git a/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/columns/headers.md b/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/columns/headers.md deleted file mode 100644 index db7d58c763..0000000000 --- a/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/columns/headers.md +++ /dev/null @@ -1,185 +0,0 @@ ---- -layout: post -title: Headers in ##Platform_Name## Grid Component -description: Learn here all about Headers in Syncfusion ##Platform_Name## Grid component of Syncfusion Essential JS 2 and more. -platform: ej2-asp-core-mvc -control: Headers -publishingplatform: ##Platform_Name## -documentation: ug ---- - -# Headers - -## Header text - -By default, column header title is displayed from column [`field`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html#Syncfusion_EJ2_Grids_GridColumn_Field) value. To override the default header title, you have to define the **headerText** value in the [`headerText`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html#Syncfusion_EJ2_Grids_GridColumn_HeaderText) property of **e-grid-column** tag helper. - -{% if page.publishingplatform == "aspnet-core" %} - -{% tabs %} -{% highlight cshtml tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/headertext/tagHelper %} -{% endhighlight %} -{% highlight c# tabtitle="Headertext.cs" %} -{% include code-snippet/grid/columns/headertext/headertext.cs %} -{% endhighlight %} -{% endtabs %} - -{% elsif page.publishingplatform == "aspnet-mvc" %} - -{% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/headertext/razor %} -{% endhighlight %} -{% highlight c# tabtitle="Headertext.cs" %} -{% include code-snippet/grid/columns/headertext/headertext.cs %} -{% endhighlight %} -{% endtabs %} -{% endif %} - - - -N> * If both the [`field`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html#Syncfusion_EJ2_Grids_GridColumn_Field) and [`headerText`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html#Syncfusion_EJ2_Grids_GridColumn_HeaderText) are not defined in the column, the column renders with “empty” header text. - -## Header template - -You can customize the header element by using the [`headerTemplate`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html#Syncfusion_EJ2_Grids_GridColumn_HeaderTemplate) property of **e-grid-column** tag helper. In this demo, the custom element is rendered for both EmployeeID and BirthDate column headers. - -{% if page.publishingplatform == "aspnet-core" %} - -{% tabs %} -{% highlight cshtml tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/headertemplate/tagHelper %} -{% endhighlight %} -{% highlight c# tabtitle="Headertemplate.cs" %} -{% include code-snippet/grid/columns/headertemplate/headertemplate.cs %} -{% endhighlight %} -{% endtabs %} - -{% elsif page.publishingplatform == "aspnet-mvc" %} - -{% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/grid/columns/headertemplate/razor %} -{% endhighlight %} -{% highlight c# tabtitle="Headertemplate.cs" %} -{% include code-snippet/grid/columns/headertemplate/headertemplate.cs %} -{% endhighlight %} -{% endtabs %} -{% endif %} - - -## Change header text dynamically - -You can change the column [`headerText`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html#Syncfusion_EJ2_Grids_GridColumn_HeaderText) dynamically through an external button. - -Follow the given steps to change the header text dynamically: - -**Step 1**: - -Get the column object corresponding to the field name by using the **getColumnByField** method. -Then, change the header text value. - -```typescript -var column = grid.getColumnByField("ShipCity"); // Get column object. -column.headerText = 'Changed Text'; - -``` - -**Step 2**: - -To reflect the changes in the grid header, invoke the **refreshHeader** method. - -```typescript -grid.refreshHeader(); - -``` - -{% if page.publishingplatform == "aspnet-core" %} - -{% tabs %} -{% highlight cshtml tabtitle="CSHTML" %} -{% include code-snippet/grid/how-to/column-header-text/tagHelper %} -{% endhighlight %} -{% highlight c# tabtitle="Column-header-text.cs" %} -{% include code-snippet/grid/how-to/column-header-text/column-header-text.cs %} -{% endhighlight %} -{% endtabs %} - -{% elsif page.publishingplatform == "aspnet-mvc" %} - -{% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/grid/how-to/column-header-text/razor %} -{% endhighlight %} -{% highlight c# tabtitle="Column-header-text.cs" %} -{% include code-snippet/grid/how-to/column-header-text/column-header-text.cs %} -{% endhighlight %} -{% endtabs %} -{% endif %} - - - -## Change the orientation of header text - -You can change the orientation of the header text by using the [`customAttributes`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html#Syncfusion_EJ2_Grids_GridColumn_CustomAttributes) property. - -Ensure the following steps: - -**Step 1**: - -Create a CSS class with orientation style for the grid header cell. - -```css -.orientationcss .e-headercelldiv { - transform: rotate(90deg); -} - -``` - -**Step 2**: - -Add the custom CSS class to a particular column by using the [`customAttributes`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html#Syncfusion_EJ2_Grids_GridColumn_CustomAttributes) property. - -```typescript - - -``` - -**Step 3**: - -Resize the header cell height by using the following code. - -```typescript -function setHeaderHeight(args) { - var textWidth = document.querySelector(".orientationcss > div").scrollWidth;//Obtain the width of the headerText content. - var headerCell = document.querySelectorAll(".e-headercell"); - for(var i = 0; i < headerCell.length; i++) { - headerCell.item(i).style.height = textWidth + 'px'; //Assign the obtained textWidth as the height of the headerCell. - } -} - -``` - -{% if page.publishingplatform == "aspnet-core" %} - -{% tabs %} -{% highlight cshtml tabtitle="CSHTML" %} -{% include code-snippet/grid/how-to/orientation/tagHelper %} -{% endhighlight %} -{% highlight c# tabtitle="Orientation.cs" %} -{% include code-snippet/grid/how-to/orientation/orientation.cs %} -{% endhighlight %} -{% endtabs %} - -{% elsif page.publishingplatform == "aspnet-mvc" %} - -{% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/grid/how-to/orientation/razor %} -{% endhighlight %} -{% highlight c# tabtitle="Orientation.cs" %} -{% include code-snippet/grid/how-to/orientation/orientation.cs %} -{% endhighlight %} -{% endtabs %} -{% endif %} diff --git a/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/how-to/customize-the-icon-for-column-menu.md b/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/how-to/customize-the-icon-for-column-menu.md deleted file mode 100644 index cfd21a6098..0000000000 --- a/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/how-to/customize-the-icon-for-column-menu.md +++ /dev/null @@ -1,49 +0,0 @@ ---- -layout: post -title: Customize The Icon For Column Menu in ##Platform_Name## Grid Component -description: Learn here all about Customize The Icon For Column Menu in Syncfusion ##Platform_Name## Grid component of Syncfusion Essential JS 2 and more. -platform: ej2-asp-core-mvc -control: Customize The Icon For Column Menu -publishingplatform: ##Platform_Name## -documentation: ug ---- - - -# Customize the icon for column menu - -You can customize the column menu icon by overriding the default grid class **.e-icons.e-columnmenu** with a custom property **content** as mentioned below, - -```css - -.e-grid .e-columnheader .e-icons.e-columnmenu::before { - content: "\e969"; -} - -``` - -In the below sample, grid is rendered with a customized column menu icon. - -{% if page.publishingplatform == "aspnet-core" %} - -{% tabs %} -{% highlight cshtml tabtitle="CSHTML" %} -{% include code-snippet/grid/how-to/custom-column-menu-icon/tagHelper %} -{% endhighlight %} -{% highlight c# tabtitle="Column-icon.cs" %} -{% include code-snippet/grid/how-to/custom-column-menu-icon/column-icon.cs %} -{% endhighlight %} -{% endtabs %} - -{% elsif page.publishingplatform == "aspnet-mvc" %} - -{% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/grid/how-to/custom-column-menu-icon/razor %} -{% endhighlight %} -{% highlight c# tabtitle="Column-icon.cs" %} -{% include code-snippet/grid/how-to/custom-column-menu-icon/column-icon.cs %} -{% endhighlight %} -{% endtabs %} -{% endif %} - - diff --git a/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/print.md b/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/print.md index 7131e9627f..a273ce4b1e 100644 --- a/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/print.md +++ b/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/print.md @@ -8,50 +8,35 @@ publishingplatform: ##Platform_Name## documentation: ug --- +# Print in ASP.NET Core Grid component -# Print in ASP.NET Core Grid Component +The printing feature in Syncfusion Grid allows you to easily generate and print a representation of the grid's content for better offline accessibility and documentation. You can enable this feature using either the grid's toolbar or the programmatically available `print` method. -To print the Grid, use the **print** method from grid instance. The print option can be displayed on the [`toolbar`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_Toolbar) by adding the **Print** toolbar item. - -{% if page.publishingplatform == "aspnet-core" %} +To add the printing option to the grid's toolbar, simply include the [toolbar](https://help.syncfusion.com/cr/aspnetcore-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_Toolbar) property in your grid configuration and add the **Print** as toolbar item. This will allow you to directly initiate the printing process while click on the Print item from the toolbar. {% tabs %} {% highlight cshtml tabtitle="CSHTML" %} {% include code-snippet/grid/print/print/tagHelper %} {% endhighlight %} -{% highlight c# tabtitle="Print.cs" %} -{% include code-snippet/grid/print/print/print.cs %} -{% endhighlight %} -{% endtabs %} - -{% elsif page.publishingplatform == "aspnet-mvc" %} - -{% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/grid/print/print/razor %} -{% endhighlight %} -{% highlight c# tabtitle="Print.cs" %} +{% highlight c# tabtitle="print.cs" %} {% include code-snippet/grid/print/print/print.cs %} {% endhighlight %} {% endtabs %} -{% endif %} - +![Print](../images/print/print.png) ## Page setup -Some of the print options cannot be configured through JavaScript code. So, you have to customize the layout, paper size, and margin options using the browser page setup dialog. Refer to the following links to know more about the browser page setup: - -* [`Chrome`](https://support.google.com/chrome/answer/1069693?hl=en&visit_id=1-636335333734668335-3165046395&rd=1) -* [`Firefox`](https://support.mozilla.org/en-US/kb/how-print-web-pages-firefox) -* [`Safari`](http://www.mintprintables.com/print-tips/adjust-margins-osx/) -* [`IE`](http://www.helpteaching.com/help/print/index.htm) +When printing a webpage, some print options, such as layout, paper size, and margin settings, cannot be configured through JavaScript code. Instead, you need to customize these settings using the browser's page setup dialog. Below are links to the page setup guides for popular web browsers: -## Print using an external button +* [Chrome](https://support.google.com/chrome/answer/1069693?hl=en&visit_id=1-636335333734668335-3165046395&rd=1) +* [Firefox](https://support.mozilla.org/en-US/kb/how-print-web-pages-firefox) +* [Safari](http://www.mintprintables.com/print-tips/adjust-margins-osx/) +* [IE](http://www.helpteaching.com/help/print/index.htm) -To print the grid from an external button, invoke the **print** method. +## Print by external button -{% if page.publishingplatform == "aspnet-core" %} +You can print the grid's content using an external button by utilizing the `print` method. This method allows you to trigger the printing process programmatically. {% tabs %} {% highlight cshtml tabtitle="CSHTML" %} @@ -62,25 +47,11 @@ To print the grid from an external button, invoke the **print** method. {% endhighlight %} {% endtabs %} -{% elsif page.publishingplatform == "aspnet-mvc" %} - -{% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/grid/print/external-btn/razor %} -{% endhighlight %} -{% highlight c# tabtitle="External-btn.cs" %} -{% include code-snippet/grid/print/external-btn/external-btn.cs %} -{% endhighlight %} -{% endtabs %} -{% endif %} - +![Print by external button](../images/print/print-external.png) +## Print visible Page -## Print the visible page - -By default, the grid prints all the pages. To print the current page alone, set the [`PrintMode`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_PrintMode) to **CurrentPage**. - -{% if page.publishingplatform == "aspnet-core" %} +By default, the Syncfusion ASP.NET Core Grid prints all the pages of the grid. The [printMode](https://help.syncfusion.com/cr/aspnetcore-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_PrintMode) property within the grid grants you control over the printing process. However, if you want to print only the current visible page, you can achieve this by setting the `printMode` property to **CurrentPage**. {% tabs %} {% highlight cshtml tabtitle="CSHTML" %} @@ -91,31 +62,36 @@ By default, the grid prints all the pages. To print the current page alone, set {% endhighlight %} {% endtabs %} -{% elsif page.publishingplatform == "aspnet-mvc" %} +![Print visible Page](../images/print/print-current.png) + +## Print only selected records + +By default, the Syncfusion ASP.NET Core Grid prints all the data bound to its dataSource. However, there might be cases where you want to print only the selected records from the grid. The ASP.NET Core Grid provides an option to achieve this by binding to the [beforePrint](https://help.syncfusion.com/cr/aspnetcore-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_BeforePrint) event, where you can replace the rows of the printing grid with the selected rows. + +Below is an example code that demonstrates how to print only the selected records from the ASP.NET Core Grid: {% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/grid/print/current-page/razor %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/print/print-select/tagHelper %} {% endhighlight %} -{% highlight c# tabtitle="Current-page.cs" %} -{% include code-snippet/grid/print/current-page/current-page.cs %} +{% highlight c# tabtitle="Print.cs" %} +{% include code-snippet/grid/print/print-select/print.cs %} {% endhighlight %} {% endtabs %} -{% endif %} - +![Print only selected records](../images/print/print-select.png) ## Print the hierarchy grid -By default, the grid will be print the master and expanded child grids alone. you can change the print option by using the [`hierarchyPrintMode`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_HierarchyPrintMode) property. The available options are, +The Syncfusion ASP.NET Core Grid allows you to print hierarchy grids, which consist of a parent grid and its child grids. By default, when you print a hierarchy grid, it includes the parent grid and expanded child grids only. However, you can customize the print behavior using the [hierarchyPrintMode](https://help.syncfusion.com/cr/aspnetcore-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_HierarchyPrintMode) property. -| Mode | Behavior | -|----------|-------------| -| Expanded | Prints the master grid with expanded child grids. | -| All | Prints the master grid with all the child grids. | -| None | Prints the master grid alone. | +The `hierarchyPrintMode` property in the ASP.NET Core Grid lets you control the printing behavior for hierarchy grids. You can choose from three options: -{% if page.publishingplatform == "aspnet-core" %} +| Mode | Behavior | +| -------- | ------------------------------------------------------------------------------- | +| Expanded | Prints the parent grid with expanded child grids. | +| All | Prints the parent grid with all the child grids, whether expanded or collapsed. | +| None | Prints the parent grid alone. | {% tabs %} {% highlight cshtml tabtitle="CSHTML" %} @@ -126,29 +102,13 @@ By default, the grid will be print the master and expanded child grids alone. yo {% endhighlight %} {% endtabs %} -{% elsif page.publishingplatform == "aspnet-mvc" %} - -{% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/grid/print/hierarchyprint/razor %} -{% endhighlight %} -{% highlight c# tabtitle="Hierarchyprint.cs" %} -{% include code-snippet/grid/print/hierarchyprint/hierarchyprint.cs %} -{% endhighlight %} -{% endtabs %} -{% endif %} - - - -N> By default, the hierarchy grid prints the expanded child grids from the visible page only. Refer [To Print the expanded state grid from all pages](./how-to/print-the-expanded-state-from-other-pages) +![Print the hierarchy grid](../images/print/print-hierachy.png) ## Print the master detail grid -The Grid has the option to visualize details of a record in another Grid in a master and detailed manner. By default, Grid will print the master grid alone. Instead of this, it is possible to print both the master and detail grids by using the [beforePrint](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_BeforePrint) event of the Grid. +The Syncfusion ASP.NET Core Grid provides the option to visualize details of a record in another grid in a master-detail manner. By default, when you print a master-detail grid, only the master grid is included in the print output. However, you can customize the print behavior to include both the master and detail grids using the `beforePrint` event of the grid. -In the following sample, the detail grid is added to the `element` argument of the `beforePrint` event, resulting in both the master and detail grids being printed on the page. - -{% if page.publishingplatform == "aspnet-core" %} +The [beforePrint](https://help.syncfusion.com/cr/aspnetcore-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_BeforePrint) event in the ASP.NET Core Grid is triggered before the actual printing process begins. You can handle this event to customize the print output. By adding the detail grid to the `element` argument of the `beforePrint` event, you can ensure that both the master and detail grids are printed on the page. {% tabs %} {% highlight cshtml tabtitle="CSHTML" %} @@ -159,37 +119,25 @@ In the following sample, the detail grid is added to the `element` argument of t {% endhighlight %} {% endtabs %} -{% elsif page.publishingplatform == "aspnet-mvc" %} - -{% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/grid/print/masterdetailgrid/razor %} -{% endhighlight %} -{% highlight c# tabtitle="Master-Detail.cs" %} -{% include code-snippet/grid/print/masterdetailgrid/masterdetailgrid.cs %} -{% endhighlight %} -{% endtabs %} -{% endif %} +![Print the master detail grid](../images/print/print-master.png) ## Print large number of columns -By default, the browser uses A4 as page size option to print pages and to adapt the size of the page the browser print preview will auto-hide the overflowed contents. Hence grid with large number of columns will cut off to adapt the print page. +When printing a grid with a large number of columns, the browser's default page size (usually A4) might not be sufficient to display all the columns properly. As a result, the browser's print preview may automatically hide the overflowed content, leading to a cut-off appearance. -To show large number of columns when printing, adjust the scale option from print option panel based on your content size. +To show a large number of columns when printing, you can adjust the scale option from the print option panel based on your content size. This will allow you to fit the entire grid content within the printable area. -![Scale Option Setting](./images/print-preview.png) +![Scale Option Setting](../images/print-preview.png) -## Show or Hide columns while Printing +## Show or hide columns while printing -You can show a hidden column or hide a visible column while printing the grid using [`toolbarClick`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ToolbarClick) and [`printComplete`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_PrintComplete) events. +In the Syncfusion ASP.NET Core Grid, you have the flexibility to control the visibility of columns during the printing process. You can dynamically show or hide specific columns using the [toolbarClick](https://help.syncfusion.com/cr/aspnetcore-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_ToolbarClick) and [printComplete](https://help.syncfusion.com/cr/aspnetcore-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_PrintComplete) events while printing. This capability enhances your control over which columns are included in the printed output, allowing you to tailor the printed grid to your specific needs. -In [`toolbarClick`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_ToolbarClick) event, based on **args.item.id** as **grid_print**. We can show or hide columns by setting [`visible`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.GridColumn.html#Syncfusion_EJ2_Grids_GridColumn_Visible) property of **e-grid-column** to **true** or **false** respectively. +In the `toolbarClick` event, you can show or hide columns by setting `column.visible` property to **true** or **false** respectively. -In [`printComplete`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_PrintComplete) event, We have reversed the state back to the previous state. +In the `printComplete` event, the column visibility state is reset back to its original configuration. -In the below example, we have **CustomerID** as a hidden column in the grid. While printing, we have changed **CustomerID** to visible column and **ShipCity** as hidden column. - -{% if page.publishingplatform == "aspnet-core" %} +Here's a code example that demonstrates how to show a hidden column (CustomerID) and hide a visible column (ShipCity) during printing and then reset their visibility after printing: {% tabs %} {% highlight cshtml tabtitle="CSHTML" %} @@ -200,26 +148,42 @@ In the below example, we have **CustomerID** as a hidden column in the grid. Whi {% endhighlight %} {% endtabs %} -{% elsif page.publishingplatform == "aspnet-mvc" %} +![Show or hide columns while printing](../images/print/print-hide.png) + +## Limitations of printing large data + +Printing a large volume of data all at once in the grid can have certain limitations due to potential browser performance issues. Rendering numerous DOM elements on a single page can lead to browser slowdowns or even hang the browser. The grid offers a solution to manage extensive datasets through virtualization. However, it's important to note that virtualization for both rows and columns is not feasible during the printing process. + +If printing all the data remains a requirement, an alternative approach is recommended. Exporting the grid data to formats like [Excel](https://ej2.syncfusion.com/aspnetcore/documentation/grid/excel-export/excel-exporting) or [CSV](https://ej2.syncfusion.com/aspnetcore/documentation/grid/excel-export/excel-exporting) or [Pdf](https://ej2.syncfusion.com/aspnetcore/documentation/grid/pdf-export/pdf-export) is advised. This exported data can then be printed using non-web-based applications, mitigating the potential performance challenges associated with printing large datasets directly from the browser. + +## Retain grid styles while printing + +The Syncfusion ASP.NET Core Grid provides a [beforePrint](https://help.syncfusion.com/cr/aspnetcore-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_BeforePrint) event that allows you to customize the appearance and styles of the grid before it is sent to the printer. By handling this event, you can ensure that the grid retains its styles and appearance while printing. {% tabs %} -{% highlight razor tabtitle="CSHTML" %} -{% include code-snippet/grid/print/show-hide-columns/razor %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/print/print-style/tagHelper %} {% endhighlight %} -{% highlight c# tabtitle="Show-hide.cs" %} -{% include code-snippet/grid/print/show-hide-columns/show-hide.cs %} +{% highlight c# tabtitle="print.cs" %} +{% include code-snippet/grid/print/print-style/print.cs %} {% endhighlight %} {% endtabs %} -{% endif %} - +![Retain grid styles while printing](../images/print/print-style.png) -## Limitations of Printing Large Data +## Print grid along with other components -When grid contains large number of data, printing all the data at once is not a best option for the browser performance. Because to render all the DOM elements in one page will produce performance issues in the browser. It leads to browser slow down or browser hang. Grid have option to handle large number of data by Virtualization. However while printing, it is not possible to use virtualization for rows and columns. +To print the Syncfusion ASP.NET Core Grid along with another component, such as a chart, you can use the [beforePrint](https://help.syncfusion.com/cr/aspnetcore-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_BeforePrint) event of the grid. In this event, you can clone the content of the other component and append it to the print document. -If printing of all the data is still needed, we suggest to Export the grid to **Excel** or **CSV** or **Pdf** and then print it from another non-web based application. +Here is an example of how to print grid along with chart component: -## See Also +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/print/print-custom/tagHelper %} +{% endhighlight %} +{% highlight c# tabtitle="print.cs" %} +{% include code-snippet/grid/print/print-custom/print.cs %} +{% endhighlight %} +{% endtabs %} -* [How to Print the expanded state grid from all pages](./how-to/print-the-expanded-state-from-other-pages) +![Print grid along with other components](../images/print/print-custom.png) diff --git a/ej2-asp-core-mvc/grid/images/column-chooser/Colum-chooser-contains.png b/ej2-asp-core-mvc/grid/images/column-chooser/Colum-chooser-contains.png new file mode 100644 index 0000000000..ffec8cbd1f Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/column-chooser/Colum-chooser-contains.png differ diff --git a/ej2-asp-core-mvc/grid/images/column-chooser/Colum-chooser-external.png b/ej2-asp-core-mvc/grid/images/column-chooser/Colum-chooser-external.png new file mode 100644 index 0000000000..3684ef4474 Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/column-chooser/Colum-chooser-external.png differ diff --git a/ej2-asp-core-mvc/grid/images/column-chooser/Colum-chooser-hide.png b/ej2-asp-core-mvc/grid/images/column-chooser/Colum-chooser-hide.png new file mode 100644 index 0000000000..15f9748537 Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/column-chooser/Colum-chooser-hide.png differ diff --git a/ej2-asp-core-mvc/grid/images/column-chooser/Colum-chooser-size.png b/ej2-asp-core-mvc/grid/images/column-chooser/Colum-chooser-size.png new file mode 100644 index 0000000000..c059d5a5eb Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/column-chooser/Colum-chooser-size.png differ diff --git a/ej2-asp-core-mvc/grid/images/column-chooser/Colum-chooser.png b/ej2-asp-core-mvc/grid/images/column-chooser/Colum-chooser.png new file mode 100644 index 0000000000..7d3b6eb3fb Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/column-chooser/Colum-chooser.png differ diff --git a/ej2-asp-core-mvc/grid/images/column-chooser/frozon-color.png b/ej2-asp-core-mvc/grid/images/column-chooser/frozon-color.png new file mode 100644 index 0000000000..e4b1da3ab0 Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/column-chooser/frozon-color.png differ diff --git a/ej2-asp-core-mvc/grid/images/column-chooser/frozon-direction.png b/ej2-asp-core-mvc/grid/images/column-chooser/frozon-direction.png new file mode 100644 index 0000000000..868c6ad337 Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/column-chooser/frozon-direction.png differ diff --git a/ej2-asp-core-mvc/grid/images/column-chooser/frozon-particular.png b/ej2-asp-core-mvc/grid/images/column-chooser/frozon-particular.png new file mode 100644 index 0000000000..77297fa5d9 Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/column-chooser/frozon-particular.png differ diff --git a/ej2-asp-core-mvc/grid/images/column-chooser/frozon.png b/ej2-asp-core-mvc/grid/images/column-chooser/frozon.png new file mode 100644 index 0000000000..845126a26e Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/column-chooser/frozon.png differ diff --git a/ej2-asp-core-mvc/grid/images/column-menu/Column-menu-custom.gif b/ej2-asp-core-mvc/grid/images/column-menu/Column-menu-custom.gif new file mode 100644 index 0000000000..2f0f632d83 Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/column-menu/Column-menu-custom.gif differ diff --git a/ej2-asp-core-mvc/grid/images/column-menu/Column-menu-particular.png b/ej2-asp-core-mvc/grid/images/column-menu/Column-menu-particular.png new file mode 100644 index 0000000000..89df32f467 Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/column-menu/Column-menu-particular.png differ diff --git a/ej2-asp-core-mvc/grid/images/column-menu/Column-menu-stacked.png b/ej2-asp-core-mvc/grid/images/column-menu/Column-menu-stacked.png new file mode 100644 index 0000000000..b03413ef8a Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/column-menu/Column-menu-stacked.png differ diff --git a/ej2-asp-core-mvc/grid/images/column-menu/Column-menu.png b/ej2-asp-core-mvc/grid/images/column-menu/Column-menu.png new file mode 100644 index 0000000000..25845f14b4 Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/column-menu/Column-menu.png differ diff --git a/ej2-asp-core-mvc/grid/images/column-menu/column-menu-events.gif b/ej2-asp-core-mvc/grid/images/column-menu/column-menu-events.gif new file mode 100644 index 0000000000..bfa9d1b39b Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/column-menu/column-menu-events.gif differ diff --git a/ej2-asp-core-mvc/grid/images/column-menu/column-menu-icon.png b/ej2-asp-core-mvc/grid/images/column-menu/column-menu-icon.png new file mode 100644 index 0000000000..0de16a9459 Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/column-menu/column-menu-icon.png differ diff --git a/ej2-asp-core-mvc/grid/images/column-rendering/column-render-array.png b/ej2-asp-core-mvc/grid/images/column-rendering/column-render-array.png new file mode 100644 index 0000000000..7cf716c2ba Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/column-rendering/column-render-array.png differ diff --git a/ej2-asp-core-mvc/grid/images/column-rendering/column-render-expression .png b/ej2-asp-core-mvc/grid/images/column-rendering/column-render-expression .png new file mode 100644 index 0000000000..479203588e Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/column-rendering/column-render-expression .png differ diff --git a/ej2-asp-core-mvc/grid/images/column-rendering/column-render-remote.png b/ej2-asp-core-mvc/grid/images/column-rendering/column-render-remote.png new file mode 100644 index 0000000000..d3c02ffe8a Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/column-rendering/column-render-remote.png differ diff --git a/ej2-asp-core-mvc/grid/images/column-rendering/column-render-serial.png b/ej2-asp-core-mvc/grid/images/column-rendering/column-render-serial.png new file mode 100644 index 0000000000..13a978790a Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/column-rendering/column-render-serial.png differ diff --git a/ej2-asp-core-mvc/grid/images/column-rendering/column-render-valueaccessor.png b/ej2-asp-core-mvc/grid/images/column-rendering/column-render-valueaccessor.png new file mode 100644 index 0000000000..79e9675eb5 Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/column-rendering/column-render-valueaccessor.png differ diff --git a/ej2-asp-core-mvc/grid/images/column-rendering/column-render.png b/ej2-asp-core-mvc/grid/images/column-rendering/column-render.png new file mode 100644 index 0000000000..3e266418f4 Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/column-rendering/column-render.png differ diff --git a/ej2-asp-core-mvc/grid/images/column-rendering/local-data.png b/ej2-asp-core-mvc/grid/images/column-rendering/local-data.png new file mode 100644 index 0000000000..c693b9941e Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/column-rendering/local-data.png differ diff --git a/ej2-asp-core-mvc/grid/images/column-reorder/column-reorder-events.gif b/ej2-asp-core-mvc/grid/images/column-reorder/column-reorder-events.gif new file mode 100644 index 0000000000..2452e2258a Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/column-reorder/column-reorder-events.gif differ diff --git a/ej2-asp-core-mvc/grid/images/column-reorder/column-reorder-field.gif b/ej2-asp-core-mvc/grid/images/column-reorder/column-reorder-field.gif new file mode 100644 index 0000000000..fa83e44603 Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/column-reorder/column-reorder-field.gif differ diff --git a/ej2-asp-core-mvc/grid/images/column-reorder/column-reorder-index.gif b/ej2-asp-core-mvc/grid/images/column-reorder/column-reorder-index.gif new file mode 100644 index 0000000000..d30cc93cc7 Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/column-reorder/column-reorder-index.gif differ diff --git a/ej2-asp-core-mvc/grid/images/column-reorder/column-reorder-prevent.gif b/ej2-asp-core-mvc/grid/images/column-reorder/column-reorder-prevent.gif new file mode 100644 index 0000000000..8d89215279 Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/column-reorder/column-reorder-prevent.gif differ diff --git a/ej2-asp-core-mvc/grid/images/column-reorder/column-reorder-target.gif b/ej2-asp-core-mvc/grid/images/column-reorder/column-reorder-target.gif new file mode 100644 index 0000000000..29fd429b3b Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/column-reorder/column-reorder-target.gif differ diff --git a/ej2-asp-core-mvc/grid/images/column-reorder/column-reorder.gif b/ej2-asp-core-mvc/grid/images/column-reorder/column-reorder.gif new file mode 100644 index 0000000000..23c2b24747 Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/column-reorder/column-reorder.gif differ diff --git a/ej2-asp-core-mvc/grid/images/column-reorder/column-reorders.gif b/ej2-asp-core-mvc/grid/images/column-reorder/column-reorders.gif new file mode 100644 index 0000000000..bffafb8a1a Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/column-reorder/column-reorders.gif differ diff --git a/ej2-asp-core-mvc/grid/images/column-resize/Colum-resize-event.gif b/ej2-asp-core-mvc/grid/images/column-resize/Colum-resize-event.gif new file mode 100644 index 0000000000..bdde9e03fd Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/column-resize/Colum-resize-event.gif differ diff --git a/ej2-asp-core-mvc/grid/images/column-resize/Colum-resize-external.png b/ej2-asp-core-mvc/grid/images/column-resize/Colum-resize-external.png new file mode 100644 index 0000000000..426ca64c44 Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/column-resize/Colum-resize-external.png differ diff --git a/ej2-asp-core-mvc/grid/images/column-resize/Colum-resize-max.gif b/ej2-asp-core-mvc/grid/images/column-resize/Colum-resize-max.gif new file mode 100644 index 0000000000..5c87e3bd23 Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/column-resize/Colum-resize-max.gif differ diff --git a/ej2-asp-core-mvc/grid/images/column-resize/Colum-resize-mode.gif b/ej2-asp-core-mvc/grid/images/column-resize/Colum-resize-mode.gif new file mode 100644 index 0000000000..8df1aaba85 Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/column-resize/Colum-resize-mode.gif differ diff --git a/ej2-asp-core-mvc/grid/images/column-resize/Colum-resize-stacked.gif b/ej2-asp-core-mvc/grid/images/column-resize/Colum-resize-stacked.gif new file mode 100644 index 0000000000..cc74f6c56c Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/column-resize/Colum-resize-stacked.gif differ diff --git a/ej2-asp-core-mvc/grid/images/column-resize/column-resize-prevent.gif b/ej2-asp-core-mvc/grid/images/column-resize/column-resize-prevent.gif new file mode 100644 index 0000000000..d5acda7024 Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/column-resize/column-resize-prevent.gif differ diff --git a/ej2-asp-core-mvc/grid/images/column-resize/column-resize.gif b/ej2-asp-core-mvc/grid/images/column-resize/column-resize.gif new file mode 100644 index 0000000000..c16ce60008 Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/column-resize/column-resize.gif differ diff --git a/ej2-asp-core-mvc/grid/images/column-resize/column-resizing.jpg b/ej2-asp-core-mvc/grid/images/column-resize/column-resizing.jpg new file mode 100644 index 0000000000..dfc194dd9c Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/column-resize/column-resizing.jpg differ diff --git a/ej2-asp-core-mvc/grid/images/columns/Column-headertext-change-alignment.gif b/ej2-asp-core-mvc/grid/images/columns/Column-headertext-change-alignment.gif new file mode 100644 index 0000000000..e7c5666b98 Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/columns/Column-headertext-change-alignment.gif differ diff --git a/ej2-asp-core-mvc/grid/images/columns/Column-headertext-change-all.gif b/ej2-asp-core-mvc/grid/images/columns/Column-headertext-change-all.gif new file mode 100644 index 0000000000..607f8e23b1 Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/columns/Column-headertext-change-all.gif differ diff --git a/ej2-asp-core-mvc/grid/images/columns/Column-headertext-change-height.gif b/ej2-asp-core-mvc/grid/images/columns/Column-headertext-change-height.gif new file mode 100644 index 0000000000..050fd9cacc Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/columns/Column-headertext-change-height.gif differ diff --git a/ej2-asp-core-mvc/grid/images/columns/Column-headertext-change.png b/ej2-asp-core-mvc/grid/images/columns/Column-headertext-change.png new file mode 100644 index 0000000000..e064471c5d Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/columns/Column-headertext-change.png differ diff --git a/ej2-asp-core-mvc/grid/images/columns/Column-headertext-headerTemplate.png b/ej2-asp-core-mvc/grid/images/columns/Column-headertext-headerTemplate.png new file mode 100644 index 0000000000..019b52f744 Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/columns/Column-headertext-headerTemplate.png differ diff --git a/ej2-asp-core-mvc/grid/images/columns/Column-headertext-orientation.png b/ej2-asp-core-mvc/grid/images/columns/Column-headertext-orientation.png new file mode 100644 index 0000000000..5600e31717 Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/columns/Column-headertext-orientation.png differ diff --git a/ej2-asp-core-mvc/grid/images/columns/Column-headertext-refresh-header.png b/ej2-asp-core-mvc/grid/images/columns/Column-headertext-refresh-header.png new file mode 100644 index 0000000000..63a4dff356 Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/columns/Column-headertext-refresh-header.png differ diff --git a/ej2-asp-core-mvc/grid/images/columns/Column-headertext-stacked.png b/ej2-asp-core-mvc/grid/images/columns/Column-headertext-stacked.png new file mode 100644 index 0000000000..2c47e3c009 Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/columns/Column-headertext-stacked.png differ diff --git a/ej2-asp-core-mvc/grid/images/columns/Column-headertext-tooltip.png b/ej2-asp-core-mvc/grid/images/columns/Column-headertext-tooltip.png new file mode 100644 index 0000000000..50518780df Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/columns/Column-headertext-tooltip.png differ diff --git a/ej2-asp-core-mvc/grid/images/columns/Column-headertext-using-css.png b/ej2-asp-core-mvc/grid/images/columns/Column-headertext-using-css.png new file mode 100644 index 0000000000..dbaccc92c1 Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/columns/Column-headertext-using-css.png differ diff --git a/ej2-asp-core-mvc/grid/images/columns/Column-headertext-using-event.png b/ej2-asp-core-mvc/grid/images/columns/Column-headertext-using-event.png new file mode 100644 index 0000000000..b293db57e2 Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/columns/Column-headertext-using-event.png differ diff --git a/ej2-asp-core-mvc/grid/images/columns/Column-headertext-using-method.png b/ej2-asp-core-mvc/grid/images/columns/Column-headertext-using-method.png new file mode 100644 index 0000000000..0ed60f7287 Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/columns/Column-headertext-using-method.png differ diff --git a/ej2-asp-core-mvc/grid/images/columns/Column-headertext-using-property.png b/ej2-asp-core-mvc/grid/images/columns/Column-headertext-using-property.png new file mode 100644 index 0000000000..d4827aceef Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/columns/Column-headertext-using-property.png differ diff --git a/ej2-asp-core-mvc/grid/images/columns/Column-headertext-wrap-mode.png b/ej2-asp-core-mvc/grid/images/columns/Column-headertext-wrap-mode.png new file mode 100644 index 0000000000..9cb20faf9d Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/columns/Column-headertext-wrap-mode.png differ diff --git a/ej2-asp-core-mvc/grid/images/columns/Column-headertext.png b/ej2-asp-core-mvc/grid/images/columns/Column-headertext.png new file mode 100644 index 0000000000..7486c63f81 Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/columns/Column-headertext.png differ diff --git a/ej2-asp-core-mvc/grid/images/columns/frozon-direction.png b/ej2-asp-core-mvc/grid/images/columns/frozon-direction.png new file mode 100644 index 0000000000..71c4032038 Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/columns/frozon-direction.png differ diff --git a/ej2-asp-core-mvc/grid/images/columns/frozon-particular.png b/ej2-asp-core-mvc/grid/images/columns/frozon-particular.png new file mode 100644 index 0000000000..77297fa5d9 Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/columns/frozon-particular.png differ diff --git a/ej2-asp-core-mvc/grid/images/columns/frozon.png b/ej2-asp-core-mvc/grid/images/columns/frozon.png new file mode 100644 index 0000000000..845126a26e Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/columns/frozon.png differ diff --git a/ej2-asp-core-mvc/grid/images/print/print-current.png b/ej2-asp-core-mvc/grid/images/print/print-current.png new file mode 100644 index 0000000000..1cc7f12905 Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/print/print-current.png differ diff --git a/ej2-asp-core-mvc/grid/images/print/print-custom.png b/ej2-asp-core-mvc/grid/images/print/print-custom.png new file mode 100644 index 0000000000..6c5f9d59a5 Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/print/print-custom.png differ diff --git a/ej2-asp-core-mvc/grid/images/print/print-external.png b/ej2-asp-core-mvc/grid/images/print/print-external.png new file mode 100644 index 0000000000..2bf6f02f50 Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/print/print-external.png differ diff --git a/ej2-asp-core-mvc/grid/images/print/print-hide.png b/ej2-asp-core-mvc/grid/images/print/print-hide.png new file mode 100644 index 0000000000..360e3a801a Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/print/print-hide.png differ diff --git a/ej2-asp-core-mvc/grid/images/print/print-hierachy.png b/ej2-asp-core-mvc/grid/images/print/print-hierachy.png new file mode 100644 index 0000000000..af1ee3e927 Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/print/print-hierachy.png differ diff --git a/ej2-asp-core-mvc/grid/images/print/print-master.png b/ej2-asp-core-mvc/grid/images/print/print-master.png new file mode 100644 index 0000000000..597d52939c Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/print/print-master.png differ diff --git a/ej2-asp-core-mvc/grid/images/print/print-preview.png b/ej2-asp-core-mvc/grid/images/print/print-preview.png new file mode 100644 index 0000000000..832b421681 Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/print/print-preview.png differ diff --git a/ej2-asp-core-mvc/grid/images/print/print-select.png b/ej2-asp-core-mvc/grid/images/print/print-select.png new file mode 100644 index 0000000000..4f8ec6e2c7 Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/print/print-select.png differ diff --git a/ej2-asp-core-mvc/grid/images/print/print-style.png b/ej2-asp-core-mvc/grid/images/print/print-style.png new file mode 100644 index 0000000000..9ed9f18402 Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/print/print-style.png differ diff --git a/ej2-asp-core-mvc/grid/images/print/print.png b/ej2-asp-core-mvc/grid/images/print/print.png new file mode 100644 index 0000000000..b00e9cfd5e Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/print/print.png differ diff --git a/ej2-asp-core-mvc/pdfviewer/EJ2_ASP.MVC/toolbar.md b/ej2-asp-core-mvc/pdfviewer/EJ2_ASP.MVC/toolbar.md index 0ded4ad8b4..06e84c4f30 100644 --- a/ej2-asp-core-mvc/pdfviewer/EJ2_ASP.MVC/toolbar.md +++ b/ej2-asp-core-mvc/pdfviewer/EJ2_ASP.MVC/toolbar.md @@ -587,10 +587,9 @@ N>The icons are embedded in the font file used in above code snippet. ``` -Sample : -[https://ej2.syncfusion.com/aspnetcore/PdfViewer/Default#/material](https://ej2.syncfusion.com/aspnetcore/PdfViewer/Default#/material) +[View sample in GitHub](https://github.com/SyncfusionExamples/asp-core-pdf-viewer-examples/tree/master/How%20to/Create%20Custom%20Toolbar) ## See also * [Toolbar customization](./how-to/toolbar_customization) -* [Feature Modules](./feature-module) \ No newline at end of file +* [Feature Modules](./feature-module) diff --git a/ej2-asp-core-toc.html b/ej2-asp-core-toc.html index e6177e8c5e..fcd0e75b0f 100644 --- a/ej2-asp-core-toc.html +++ b/ej2-asp-core-toc.html @@ -84,6 +84,7 @@
  • Size Modes
  • Theme Studio
  • Icons
  • +
  • Figma UI Kits
  • @@ -898,7 +899,12 @@
  • Feature modules
  • Import
  • Export
  • -
  • Collaborative Editing
  • +
  • Collaborative Editing + +
  • Images
  • Shapes
  • Text Wrapping Style
  • @@ -1254,14 +1260,14 @@
  • Immutable Mode
  • Columns
  • Common @@ -847,7 +848,12 @@
  • Feature modules
  • Import
  • Export
  • -
  • Collaborative Editing
  • +
  • Collaborative Editing + +
  • Images
  • Shapes
  • Text Wrapping Style
  • @@ -1204,14 +1210,14 @@
  • Immutable Mode
  • Columns