diff --git a/applications/GettingStartedWith/DataGrid/index.js b/applications/GettingStartedWith/DataGrid/index.js index 7b24b6f8f5..9d51846d33 100644 --- a/applications/GettingStartedWith/DataGrid/index.js +++ b/applications/GettingStartedWith/DataGrid/index.js @@ -1,17 +1,15 @@ -const polyfill = $(" - - const employees = [{ - "EmployeeID": 1, - "FullName": "Nancy Davolio", - "Position": "Sales Representative", - "TitleOfCourtesy": "Ms.", - "BirthDate": "1968-12-08T00:00:00.000Z", - "HireDate": "2011-05-01T00:00:00.000Z", - "Address": "507 - 20th Ave. E.\r\nApt. 2A", - "City": "Seattle", - "Region": "WA", - "PostalCode": "98122", - "Country": "USA", - "HomePhone": "(206) 555-9857", - "Extension": "5467", - "Photo": "https://js.devexpress.com/Demos/WidgetsGallery/JSDemos/images/employees/06.png", - "Notes": "Education includes a BA in psychology from Colorado State University in 1990. She also completed \"The Art of the Cold Call.\" Nancy is a member of Toastmasters International.", - "ReportsTo": 2 - }, { - "EmployeeID": 2, - "FullName": "Andrew Fuller", - "Position": "Vice President, Sales", - "TitleOfCourtesy": "Dr.", - "BirthDate": "1972-02-19T00:00:00.000Z", - "HireDate": "2011-08-14T00:00:00.000Z", - "Address": "908 W. Capital Way", - "City": "Tacoma", - "Region": "WA", - "PostalCode": "98401", - "Country": "USA", - "HomePhone": "(206) 555-9482", - "Extension": "3457", - "Photo": "https://js.devexpress.com/Demos/WidgetsGallery/JSDemos/images/employees/02.png", - "Notes": "Andrew received his BTS commercial in 1994 and a Ph.D. in international marketing from the University of Dallas in 2001. He is fluent in French and Italian and reads German. He joined the company as a sales representative, was promoted to sales manager in January 2012 and to vice president of sales in March 2013. Andrew is a member of the Sales Management Roundtable, the Seattle Chamber of Commerce, and the Pacific Rim Importers Association.", - "ReportsTo": null - }, { - "EmployeeID": 3, - "FullName": "Janet Leverling", - "Position": "Sales Representative", - "TitleOfCourtesy": "Ms.", - "BirthDate": "1983-08-30T00:00:00.000Z", - "HireDate": "2011-04-01T00:00:00.000Z", - "Address": "722 Moss Bay Blvd.", - "City": "Kirkland", - "Region": "WA", - "PostalCode": "98033", - "Country": "USA", - "HomePhone": "(206) 555-3412", - "Extension": "3355", - "Photo": "https://js.devexpress.com/Demos/WidgetsGallery/JSDemos/images/employees/09.png", - "Notes": "Janet has a BS degree in chemistry from Boston College (2004). She has also completed a certificate program in food retailing management. Janet was hired as a sales associate in 2011 and promoted to sales representative in February 2012.", - "ReportsTo": 2 - }, { - "EmployeeID": 4, - "FullName": "Margaret Peacock", - "Position": "Sales Representative", - "TitleOfCourtesy": "Mrs.", - "BirthDate": "1957-09-19T00:00:00.000Z", - "HireDate": "2012-05-03T00:00:00.000Z", - "Address": "4110 Old Redmond Rd.", - "City": "Redmond", - "Region": "WA", - "PostalCode": "98052", - "Country": "USA", - "HomePhone": "(206) 555-8122", - "Extension": "5176", - "Photo": "https://js.devexpress.com/Demos/WidgetsGallery/JSDemos/images/employees/04.png", - "Notes": "Margaret holds a BA in English literature from Concordia College (1978) and an MA from the American Institute of Culinary Arts (1986). She was assigned to the London office temporarily from July through November 2012.", - "ReportsTo": 2 - }, { - "EmployeeID": 5, - "FullName": "Steven Buchanan", - "Position": "Sales Manager", - "TitleOfCourtesy": "Mr.", - "BirthDate": "1975-03-04T00:00:00.000Z", - "HireDate": "2012-10-17T00:00:00.000Z", - "Address": "14 Garrett Hill", - "City": "London", - "Region": "UK", - "PostalCode": "SW1 8JR", - "Country": "UK", - "HomePhone": "(71) 555-4848", - "Extension": "3453", - "Photo": "https://js.devexpress.com/Demos/WidgetsGallery/JSDemos/images/employees/05.png", - "Notes": "Steven Buchanan graduated from St. Andrews University, Scotland, with a BSC degree in 1996. Upon joining the company as a sales representative in 2012, he spent 6 months in an orientation program at the Seattle office and then returned to his permanent post in London. He was promoted to sales manager in March 2013. Mr. Buchanan has completed the courses \"Successful Telemarketing\" and \"International Sales Management.\" He is fluent in French.", - "ReportsTo": 2 - }, { - "EmployeeID": 6, - "FullName": "Michael Suyama", - "Position": "Sales Representative", - "TitleOfCourtesy": "Mr.", - "BirthDate": "1983-07-02T00:00:00.000Z", - "HireDate": "2012-10-17T00:00:00.000Z", - "Address": "Coventry House\r\nMiner Rd.", - "City": "London", - "Region": "UK", - "PostalCode": "EC2 7JR", - "Country": "UK", - "HomePhone": "(71) 555-7773", - "Extension": "428", - "Photo": "https://js.devexpress.com/Demos/WidgetsGallery/JSDemos/images/employees/01.png", - "Notes": "Michael is a graduate of Sussex University (MA, economics, 2003) and the University of California at Los Angeles (MBA, marketing, 2006). He has also taken the courses \"Multi-Cultural Selling\" and \"Time Management for the Sales Professional.\" He is fluent in Japanese and can read and write French, Portuguese, and Spanish.", - "ReportsTo": 5 - }, { - "EmployeeID": 7, - "FullName": "Robert King", - "Position": "Sales Representative", - "TitleOfCourtesy": "Mr.", - "BirthDate": "1980-05-29T00:00:00.000Z", - "HireDate": "2012-01-02T00:00:00.000Z", - "Address": "Edgeham Hollow\r\nWinchester Way", - "City": "London", - "Region": "UK", - "PostalCode": "RG1 9SP", - "Country": "UK", - "HomePhone": "(71) 555-5598", - "Extension": "465", - "Photo": "https://js.devexpress.com/Demos/WidgetsGallery/JSDemos/images/employees/07.png", - "Notes": "Robert King served in the Peace Corps and traveled extensively before completing his degree in English at the University of Michigan in 2002, the year he joined the company. After completing a course entitled \"Selling in Europe,\" he was transferred to the London office in March 2013.", - "ReportsTo": 5 - }, { - "EmployeeID": 8, - "FullName": "Laura Callahan", - "Position": "Inside Sales Coordinator", - "TitleOfCourtesy": "Ms.", - "BirthDate": "1978-01-09T00:00:00.000Z", - "HireDate": "2012-03-05T00:00:00.000Z", - "Address": "4726 - 11th Ave. N.E.", - "City": "Seattle", - "Region": "WA", - "PostalCode": "98105", - "Country": "USA", - "HomePhone": "(206) 555-1189", - "Extension": "2344", - "Photo": "https://js.devexpress.com/Demos/WidgetsGallery/JSDemos/images/employees/08.png", - "Notes": "Laura received a BA in psychology from the University of Washington. She has also completed a course in business French. She reads and writes French.", - "ReportsTo": 2 - }, { - "EmployeeID": 9, - "FullName": "Brett Wade", - "Position": "Sales Representative", - "TitleOfCourtesy": "Mr.", - "BirthDate": "1986-01-27T00:00:00.000Z", - "HireDate": "2012-11-15T00:00:00.000Z", - "Address": "7 Houndstooth Rd.", - "City": "London", - "Region": "UK", - "PostalCode": "WG2 7LT", - "Country": "UK", - "HomePhone": "(71) 555-4444", - "Extension": "452", - "Photo": "https://js.devexpress.com/Demos/WidgetsGallery/JSDemos/images/employees/03.png", - "Notes": "Brett has a BA degree in English from St. Lawrence College. He is fluent in French and German.", - "ReportsTo": 5 - }]; - - export default { - getEmployees() { - return employees; - } + + export interface Employee { + EmployeeID: number; + FullName: string; + Position: string; + TitleOfCourtesy: string; + BirthDate: string; + HireDate: string; + Address: string; + City: string; + Region: string | null; + PostalCode: string; + Country: string; + HomePhone: string; + Extension: string; + Photo: string; + Notes: string; + ReportsTo: number | null; } -##### React + const employees = [ + // ... + ]; - - import React from 'react'; + export function getEmployees(): Employee[] { + return employees; + } - import 'devextreme/dist/css/dx.fluent.blue.light.css'; +##### React - import { - DataGrid - } from 'devextreme-react/data-grid'; + + // ... import { employees } from './employees'; function App() { @@ -594,166 +198,37 @@ The DataGrid component can load and update data from different data source types ); } - export default App; - - - export const employees = [{ - "EmployeeID": 1, - "FullName": "Nancy Davolio", - "Position": "Sales Representative", - "TitleOfCourtesy": "Ms.", - "BirthDate": "1968-12-08T00:00:00.000Z", - "HireDate": "2011-05-01T00:00:00.000Z", - "Address": "507 - 20th Ave. E.\r\nApt. 2A", - "City": "Seattle", - "Region": "WA", - "PostalCode": "98122", - "Country": "USA", - "HomePhone": "(206) 555-9857", - "Extension": "5467", - "Photo": "https://js.devexpress.com/Demos/WidgetsGallery/JSDemos/images/employees/06.png", - "Notes": "Education includes a BA in psychology from Colorado State University in 1990. She also completed \"The Art of the Cold Call.\" Nancy is a member of Toastmasters International.", - "ReportsTo": 2 - }, { - "EmployeeID": 2, - "FullName": "Andrew Fuller", - "Position": "Vice President, Sales", - "TitleOfCourtesy": "Dr.", - "BirthDate": "1972-02-19T00:00:00.000Z", - "HireDate": "2011-08-14T00:00:00.000Z", - "Address": "908 W. Capital Way", - "City": "Tacoma", - "Region": "WA", - "PostalCode": "98401", - "Country": "USA", - "HomePhone": "(206) 555-9482", - "Extension": "3457", - "Photo": "https://js.devexpress.com/Demos/WidgetsGallery/JSDemos/images/employees/02.png", - "Notes": "Andrew received his BTS commercial in 1994 and a Ph.D. in international marketing from the University of Dallas in 2001. He is fluent in French and Italian and reads German. He joined the company as a sales representative, was promoted to sales manager in January 2012 and to vice president of sales in March 2013. Andrew is a member of the Sales Management Roundtable, the Seattle Chamber of Commerce, and the Pacific Rim Importers Association.", - "ReportsTo": null - }, { - "EmployeeID": 3, - "FullName": "Janet Leverling", - "Position": "Sales Representative", - "TitleOfCourtesy": "Ms.", - "BirthDate": "1983-08-30T00:00:00.000Z", - "HireDate": "2011-04-01T00:00:00.000Z", - "Address": "722 Moss Bay Blvd.", - "City": "Kirkland", - "Region": "WA", - "PostalCode": "98033", - "Country": "USA", - "HomePhone": "(206) 555-3412", - "Extension": "3355", - "Photo": "https://js.devexpress.com/Demos/WidgetsGallery/JSDemos/images/employees/09.png", - "Notes": "Janet has a BS degree in chemistry from Boston College (2004). She has also completed a certificate program in food retailing management. Janet was hired as a sales associate in 2011 and promoted to sales representative in February 2012.", - "ReportsTo": 2 - }, { - "EmployeeID": 4, - "FullName": "Margaret Peacock", - "Position": "Sales Representative", - "TitleOfCourtesy": "Mrs.", - "BirthDate": "1957-09-19T00:00:00.000Z", - "HireDate": "2012-05-03T00:00:00.000Z", - "Address": "4110 Old Redmond Rd.", - "City": "Redmond", - "Region": "WA", - "PostalCode": "98052", - "Country": "USA", - "HomePhone": "(206) 555-8122", - "Extension": "5176", - "Photo": "https://js.devexpress.com/Demos/WidgetsGallery/JSDemos/images/employees/04.png", - "Notes": "Margaret holds a BA in English literature from Concordia College (1978) and an MA from the American Institute of Culinary Arts (1986). She was assigned to the London office temporarily from July through November 2012.", - "ReportsTo": 2 - }, { - "EmployeeID": 5, - "FullName": "Steven Buchanan", - "Position": "Sales Manager", - "TitleOfCourtesy": "Mr.", - "BirthDate": "1975-03-04T00:00:00.000Z", - "HireDate": "2012-10-17T00:00:00.000Z", - "Address": "14 Garrett Hill", - "City": "London", - "Region": "UK", - "PostalCode": "SW1 8JR", - "Country": "UK", - "HomePhone": "(71) 555-4848", - "Extension": "3453", - "Photo": "https://js.devexpress.com/Demos/WidgetsGallery/JSDemos/images/employees/05.png", - "Notes": "Steven Buchanan graduated from St. Andrews University, Scotland, with a BSC degree in 1996. Upon joining the company as a sales representative in 2012, he spent 6 months in an orientation program at the Seattle office and then returned to his permanent post in London. He was promoted to sales manager in March 2013. Mr. Buchanan has completed the courses \"Successful Telemarketing\" and \"International Sales Management.\" He is fluent in French.", - "ReportsTo": 2 - }, { - "EmployeeID": 6, - "FullName": "Michael Suyama", - "Position": "Sales Representative", - "TitleOfCourtesy": "Mr.", - "BirthDate": "1983-07-02T00:00:00.000Z", - "HireDate": "2012-10-17T00:00:00.000Z", - "Address": "Coventry House\r\nMiner Rd.", - "City": "London", - "Region": "UK", - "PostalCode": "EC2 7JR", - "Country": "UK", - "HomePhone": "(71) 555-7773", - "Extension": "428", - "Photo": "https://js.devexpress.com/Demos/WidgetsGallery/JSDemos/images/employees/01.png", - "Notes": "Michael is a graduate of Sussex University (MA, economics, 2003) and the University of California at Los Angeles (MBA, marketing, 2006). He has also taken the courses \"Multi-Cultural Selling\" and \"Time Management for the Sales Professional.\" He is fluent in Japanese and can read and write French, Portuguese, and Spanish.", - "ReportsTo": 5 - }, { - "EmployeeID": 7, - "FullName": "Robert King", - "Position": "Sales Representative", - "TitleOfCourtesy": "Mr.", - "BirthDate": "1980-05-29T00:00:00.000Z", - "HireDate": "2012-01-02T00:00:00.000Z", - "Address": "Edgeham Hollow\r\nWinchester Way", - "City": "London", - "Region": "UK", - "PostalCode": "RG1 9SP", - "Country": "UK", - "HomePhone": "(71) 555-5598", - "Extension": "465", - "Photo": "https://js.devexpress.com/Demos/WidgetsGallery/JSDemos/images/employees/07.png", - "Notes": "Robert King served in the Peace Corps and traveled extensively before completing his degree in English at the University of Michigan in 2002, the year he joined the company. After completing a course entitled \"Selling in Europe,\" he was transferred to the London office in March 2013.", - "ReportsTo": 5 - }, { - "EmployeeID": 8, - "FullName": "Laura Callahan", - "Position": "Inside Sales Coordinator", - "TitleOfCourtesy": "Ms.", - "BirthDate": "1978-01-09T00:00:00.000Z", - "HireDate": "2012-03-05T00:00:00.000Z", - "Address": "4726 - 11th Ave. N.E.", - "City": "Seattle", - "Region": "WA", - "PostalCode": "98105", - "Country": "USA", - "HomePhone": "(206) 555-1189", - "Extension": "2344", - "Photo": "https://js.devexpress.com/Demos/WidgetsGallery/JSDemos/images/employees/08.png", - "Notes": "Laura received a BA in psychology from the University of Washington. She has also completed a course in business French. She reads and writes French.", - "ReportsTo": 2 - }, { - "EmployeeID": 9, - "FullName": "Brett Wade", - "Position": "Sales Representative", - "TitleOfCourtesy": "Mr.", - "BirthDate": "1986-01-27T00:00:00.000Z", - "HireDate": "2012-11-15T00:00:00.000Z", - "Address": "7 Houndstooth Rd.", - "City": "London", - "Region": "UK", - "PostalCode": "WG2 7LT", - "Country": "UK", - "HomePhone": "(71) 555-4444", - "Extension": "452", - "Photo": "https://js.devexpress.com/Demos/WidgetsGallery/JSDemos/images/employees/03.png", - "Notes": "Brett has a BA degree in English from St. Lawrence College. He is fluent in French and German.", - "ReportsTo": 5 - }]; + + export interface Employee { + EmployeeID: number; + FullName: string; + Position: string; + TitleOfCourtesy: string; + BirthDate: string; + HireDate: string; + Address: string; + City: string; + Region: string | null; + PostalCode: string; + Country: string; + HomePhone: string; + Extension: string; + Photo: string; + Notes: string; + ReportsTo: number | null; + } + + export const employees = [ + // ... + ]; --- -If you run this code, a DataGrid is created with a column for each data field. All the columns have equal widths and the same order as their data fields. +To use another data source type, refer to the following help topics: + +- [Read-Only Data in JSON Format](/concepts/70%20Data%20Binding/00%20Specify%20a%20Data%20Source/20%20Read-Only%20Data%20in%20JSON%20Format.md '/Documentation/Guide/Data_Binding/Specify_a_Data_Source/Read-Only_Data_in_JSON_Format/') +- [Web API and MongoDB](/concepts/70%20Data%20Binding/00%20Specify%20a%20Data%20Source/30%20Web%20API%20and%20MongoDB.md '/Documentation/Guide/Data_Binding/Specify_a_Data_Source/Web_API_and_MongoDB/') +- [OData](/concepts/70%20Data%20Binding/00%20Specify%20a%20Data%20Source/40%20OData.md '/Documentation/Guide/Data_Binding/Specify_a_Data_Source/OData/') +- [Custom Data Sources](/concepts/70%20Data%20Binding/00%20Specify%20a%20Data%20Source/60%20Custom%20Data%20Sources '/Documentation/Guide/Data_Binding/Specify_a_Data_Source/Custom_Data_Sources/') [tags] data binding \ No newline at end of file diff --git a/concepts/05 UI Components/DataGrid/00 Getting Started with DataGrid/10 Customize Columns/0 Customize Columns.md b/concepts/05 UI Components/DataGrid/00 Getting Started with DataGrid/10 Customize Columns/0 Customize Columns.md index 6aada89cc7..aa5f673e8f 100644 --- a/concepts/05 UI Components/DataGrid/00 Getting Started with DataGrid/10 Customize Columns/0 Customize Columns.md +++ b/concepts/05 UI Components/DataGrid/00 Getting Started with DataGrid/10 Customize Columns/0 Customize Columns.md @@ -1 +1,21 @@ -To customize grid columns, declare the [columns](/api-reference/10%20UI%20Components/dxDataGrid/1%20Configuration/columns '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/columns/') array. This array can contain objects (column configurations) or text strings (data field names). You can use text strings if you do not need to specify column properties except the [dataField](/api-reference/10%20UI%20Components/dxDataGrid/1%20Configuration/columns/dataField.md '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/columns/#dataField'). \ No newline at end of file +--- + +##### jQuery + +Specify the [columns](/api-reference/10%20UI%20Components/dxDataGrid/1%20Configuration/columns '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/columns/') array to define and customize DataGrid columns. You can define columns as objects to configure options. To add a column with default options, add the column's [dataField](/api-reference/10%20UI%20Components/dxDataGrid/1%20Configuration/columns/dataField.md '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/columns/#dataField') value to **columns[]** as a string. + +##### Angular + +Specify the [columns](/api-reference/10%20UI%20Components/dxDataGrid/1%20Configuration/columns '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/columns/') array to define and customize DataGrid columns. To add a column, specify the [dataField](/api-reference/10%20UI%20Components/dxDataGrid/1%20Configuration/columns/dataField.md '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/columns/#dataField') value. + +##### Vue + +Specify the [columns](/api-reference/10%20UI%20Components/dxDataGrid/1%20Configuration/columns '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/columns/') array to define and customize DataGrid columns. To add a column, specify the [dataField](/api-reference/10%20UI%20Components/dxDataGrid/1%20Configuration/columns/dataField.md '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/columns/#dataField') value. + +##### React + +Specify the [columns](/api-reference/10%20UI%20Components/dxDataGrid/1%20Configuration/columns '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/columns/') array to define and customize DataGrid columns. To add a column, specify the [dataField](/api-reference/10%20UI%20Components/dxDataGrid/1%20Configuration/columns/dataField.md '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/columns/#dataField') value. + +--- + +Read Tutorial: Columns - Overview diff --git a/concepts/05 UI Components/DataGrid/00 Getting Started with DataGrid/10 Customize Columns/3 Reorder Columns.md b/concepts/05 UI Components/DataGrid/00 Getting Started with DataGrid/10 Customize Columns/3 Reorder Columns.md index 75a31439e1..24ede19bba 100644 --- a/concepts/05 UI Components/DataGrid/00 Getting Started with DataGrid/10 Customize Columns/3 Reorder Columns.md +++ b/concepts/05 UI Components/DataGrid/00 Getting Started with DataGrid/10 Customize Columns/3 Reorder Columns.md @@ -1,39 +1,56 @@ -To reorder grid columns, change their order in the [columns](/api-reference/10%20UI%20Components/dxDataGrid/1%20Configuration/columns '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/columns/') array. Users can also reorder columns if you enable the [allowColumnReordering](/api-reference/10%20UI%20Components/GridBase/1%20Configuration/allowColumnReordering.md '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/#allowColumnReordering') property. +To specify an initial column order, reorder [columns[]](/api-reference/10%20UI%20Components/dxDataGrid/1%20Configuration/columns '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/columns/') items. Enable [allowColumnReordering](/api-reference/10%20UI%20Components/GridBase/1%20Configuration/allowColumnReordering.md '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/#allowColumnReordering') to allow column reordering in the component's UI. + +The following code snippet also specifies [dataType](/api-reference/_hidden/GridBaseColumn/dataType.md '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/columns/#dataType') for `BirthDate` and `HireDate` columns to display string values as dates: --- ##### jQuery - $(function() { - $("#dataGrid").dxDataGrid({ - // ... - columns: [{ - dataField: "FullName" - }, { - dataField: "Position" - }, { - dataField: "BirthDate", - dataType: "date", - }, { - dataField: "HireDate", - dataType: "date", - },"City", { - dataField: "Country" - }, - "Address", - "HomePhone", - { - dataField: "PostalCode", - }], - allowColumnReordering: true, - }); + $("#dataGrid").dxDataGrid({ + columns: [{ + dataField: "FullName" + }, { + dataField: "Position" + }, { + dataField: "BirthDate", + dataType: "date", + }, { + dataField: "HireDate", + dataType: "date", + },"City", { + dataField: "Country" + }, + "Address", + "HomePhone", + { + dataField: "PostalCode", + }], + allowColumnReordering: true, }); +##### ASP.NET Core Controls + + + @(Html.DevExtreme().DataGrid() + .Columns(columns => { + columns.AddFor(m => m.FullName); + columns.AddFor(m => m.Position); + columns.AddFor(m => m.BirthDate) + .DataType(GridColumnDataType.Date); + columns.AddFor(m => m.HireDate) + .DataType(GridColumnDataType.Date); + columns.AddFor(m => m.Country); + columns.AddFor(m => m.Address); + columns.AddFor(m => m.HomePhone); + columns.AddFor(m => m.PostalCode).Visible(false); + }) + @* ... *@ + ) + ##### Angular - + - ##### React - - import React from 'react'; - import 'devextreme/dist/css/dx.fluent.blue.light.css'; - - import { - DataGrid, - Column - } from 'devextreme-react/data-grid'; + + import { DataGrid, Column } from 'devextreme-react/data-grid'; function App() { return ( -
- - - - - - - - - - - - - -
+ + + + + + + + + + + + + ); } - export default App; - --- -In the code above, we also specify the *"date"* [dataType](/api-reference/_hidden/GridBaseColumn/dataType.md '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/columns/#dataType') for the `BirthDate` and `HireDate` columns because `BirthDate` and `HireDate` are stored as strings, but you want the DataGrid to treat them as date-time values. \ No newline at end of file +Read Tutorial: Column Reordering diff --git a/concepts/05 UI Components/DataGrid/00 Getting Started with DataGrid/10 Customize Columns/5 Resize Columns.md b/concepts/05 UI Components/DataGrid/00 Getting Started with DataGrid/10 Customize Columns/5 Resize Columns.md index 074722ef4b..fc6ced907d 100644 --- a/concepts/05 UI Components/DataGrid/00 Getting Started with DataGrid/10 Customize Columns/5 Resize Columns.md +++ b/concepts/05 UI Components/DataGrid/00 Getting Started with DataGrid/10 Customize Columns/5 Resize Columns.md @@ -1,47 +1,58 @@ -Grid columns have equal widths by default. You can set each column's [width](/api-reference/_hidden/GridBaseColumn/width.md '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/columns/#width') or indicate that all columns should adjust their widths to their content ([columnAutoWidth](/api-reference/10%20UI%20Components/GridBase/1%20Configuration/columnAutoWidth.md '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/#columnAutoWidth')). Users can resize columns if you enable the [allowColumnResizing](/api-reference/10%20UI%20Components/GridBase/1%20Configuration/allowColumnResizing.md '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/#allowColumnResizing') property. +DataGrid columns have equal widths in the default configuration ([width](/api-reference/_hidden/GridBaseColumn/width.md '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/columns/#width') is set to *"auto"*). To change the column layout, you can define each column's **width** property or enable [columnAutoWidth](/api-reference/10%20UI%20Components/GridBase/1%20Configuration/columnAutoWidth.md '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/#columnAutoWidth') to adjust all columns to fit cell values. To allow users to change the column layout, enable [allowColumnResizing](/api-reference/10%20UI%20Components/GridBase/1%20Configuration/allowColumnResizing.md '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/#allowColumnResizing'). --- ##### jQuery - $(function() { - $("#dataGrid").dxDataGrid({ - // ... - columns: [ - // ... - { - dataField: "BirthDate", - dataType: "date", - width: 100, - }, { - dataField: "HireDate", - dataType: "date", - width: 100, - }, - // ... - ], - allowColumnResizing: true, - columnAutoWidth: true, - }); + $("#dataGrid").dxDataGrid({ + allowColumnResizing: true, + columnAutoWidth: true, + columns: [{ + dataField: "BirthDate", + dataType: "date", + width: 100, + }, { + dataField: "HireDate", + dataType: "date", + width: 100, + }, /* ... */ ], + // ... }); +##### ASP.NET Core Controls + + + @(Html.DevExtreme().DataGrid() + .AllowColumnResizing(true) + .ColumnAutoWidth(true) + .Columns(columns => { + columns.AddFor(m => m.BirthDate) + .DataType(GridColumnDataType.Date) + .Width(100); + columns.AddFor(m => m.HireDate) + .DataType(GridColumnDataType.Date) + .Width(100); + }) + @* ... *@ + ) + ##### Angular - - + [columnAutoWidth]="true" + > - + [width]="100" + >
- + [width]="100" + >
@@ -49,75 +60,55 @@ Grid columns have equal widths by default. You can set each column's [width](/ap - ##### React - - import React from 'react'; - import 'devextreme/dist/css/dx.fluent.blue.light.css'; - - import { - DataGrid, - Column - } from 'devextreme-react/data-grid'; + + import { DataGrid, Column } from 'devextreme-react/data-grid'; function App() { return ( -
- - {/* ... */} - - - - - {/* ... */} - -
+ + + + {/* ... */} + ); } - export default App; +--- ---- \ No newline at end of file +Read Tutorial: Column Sizing diff --git a/concepts/05 UI Components/DataGrid/00 Getting Started with DataGrid/10 Customize Columns/6 Fix Columns.md b/concepts/05 UI Components/DataGrid/00 Getting Started with DataGrid/10 Customize Columns/6 Fix Columns.md index eb2ba2c001..b6f2f4b1b3 100644 --- a/concepts/05 UI Components/DataGrid/00 Getting Started with DataGrid/10 Customize Columns/6 Fix Columns.md +++ b/concepts/05 UI Components/DataGrid/00 Getting Started with DataGrid/10 Customize Columns/6 Fix Columns.md @@ -1,100 +1,81 @@ -When the width of all columns exceeds the UI component's width, users can scroll the grid horizontally. If you set the [columnFixing](/api-reference/10%20UI%20Components/GridBase/1%20Configuration/columnFixing '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/columnFixing/').[enabled](/api-reference/10%20UI%20Components/GridBase/1%20Configuration/columnFixing/enabled.md '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/columnFixing/#enabled') property to **true**, users can show certain columns in the view regardless of how far they scroll the grid. - -You can also enable a column's [fixed](/api-reference/_hidden/GridBaseColumn/fixed.md '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/columns/#fixed') property in code. This fixes the column to the UI component's left edge. To change the position, set the [fixedPosition](/api-reference/_hidden/GridBaseColumn/fixedPosition.md '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/columns/#fixedPosition') property. - -The following code fixes the `FullName` column to the default position and allows users to fix and unfix columns at runtime: +When the width of all columns exceeds the UI component's width, DataGrid enables horizontal scrolling. To ensure specific columns always remain in view, enable [columnFixing](/api-reference/10%20UI%20Components/GridBase/1%20Configuration/columnFixing/enabled.md '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/columnFixing/#enabled'). Set **columns[]**.[fixed](/api-reference/_hidden/GridBaseColumn/fixed.md '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/columns/#fixed') to `true` to initialize fixed columns. Define [fixedPosition](/api-reference/_hidden/GridBaseColumn/fixedPosition.md '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/columns/#fixedPosition') to specify a fixed column's position or implement a sticky column. Users can also modify column fixing options in the component UI using the DataGrid [context menu](/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/#onContextMenuPreparing). --- ##### jQuery - $(function() { - $("#dataGrid").dxDataGrid({ - // ... - columnFixing: { enabled: true }, - columns: [{ - dataField: "FullName", - fixed: true - }, - // ... - ], - // ... - }); + $("#dataGrid").dxDataGrid({ + columnFixing: { enabled: true }, + columns: [{ + dataField: "FullName", + fixed: true + }, /* ... */ ], + // ... }); +##### ASP.NET Core Controls + + + @(Html.DevExtreme().DataGrid() + .ColumnFixing(c => c.Enabled(true)) + .Columns(columns => { + columns.AddFor(m => m.FullName) + .Fixed(true); + }) + @* ... *@ + ) + ##### Angular - + + - + [fixed]="true" + > - ##### Vue - ##### React - - import React from 'react'; - import 'devextreme/dist/css/dx.fluent.blue.light.css'; - - import { - DataGrid, - Column, - ColumnFixing - } from 'devextreme-react/data-grid'; + + import { DataGrid, ColumnFixing, Column } from 'devextreme-react/data-grid'; function App() { return (
- - {/* ... */} + + - + fixed={true} + /> {/* ... */} -
); } - export default App; - --- + +Read Tutorial: Column Fixing diff --git a/concepts/05 UI Components/DataGrid/00 Getting Started with DataGrid/10 Customize Columns/8 Hide Columns.md b/concepts/05 UI Components/DataGrid/00 Getting Started with DataGrid/10 Customize Columns/8 Hide Columns.md index b2dbe77aae..3cf6cc348f 100644 --- a/concepts/05 UI Components/DataGrid/00 Getting Started with DataGrid/10 Customize Columns/8 Hide Columns.md +++ b/concepts/05 UI Components/DataGrid/00 Getting Started with DataGrid/10 Customize Columns/8 Hide Columns.md @@ -1,85 +1,81 @@ -The DataGrid displays all columns from the [columns](/api-reference/10%20UI%20Components/dxDataGrid/1%20Configuration/columns '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/columns/') array. To hide a column, set its [visible](/api-reference/_hidden/GridBaseColumn/visible.md '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/columns/#visible') property to **false**. Hidden columns appear in the [columnChooser](/api-reference/10%20UI%20Components/GridBase/1%20Configuration/columnChooser '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/columnChooser/'). Users can restore hidden columns from it. To enable the column chooser, set the **columnChooser**.[enabled](/api-reference/40%20Common%20Types/15%20grids/ColumnChooser/enabled.md '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/columnChooser/#enabled') property to **true**. If a column should not be visible even in the column chooser, do not declare it in the [columns](/api-reference/10%20UI%20Components/dxDataGrid/1%20Configuration/columns '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/columns/') array. +To hide a DataGrid column, set **columns[]**.[visible](/api-reference/_hidden/GridBaseColumn/visible.md '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/columns/#visible') to `false`. Users can restore hidden columns if you enable the [columnChooser](/api-reference/40%20Common%20Types/15%20grids/ColumnChooser/enabled.md '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/columnChooser/#enabled'). To hide a column in the component and the column chooser, omit the corresponding [columns[]](/api-reference/10%20UI%20Components/dxDataGrid/1%20Configuration/columns '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/columns/') item. --- ##### jQuery - $(function() { - $("#dataGrid").dxDataGrid({ - // ... - columns: [ - // ... - { - dataField: "PostalCode", - visible: false - }], - columnChooser: { enabled: true }, - }); + $("#dataGrid").dxDataGrid({ + columnChooser: { enabled: true }, + columns: [{ + dataField: "PostalCode", + visible: false + }, /* ... */ ], + // ... }); +##### ASP.NET Core Controls + + + @(Html.DevExtreme().DataGrid() + .ColumnChooser(c => c.Enabled(true)) + .Columns(columns => { + columns.AddFor(m => m.PostalCode) + .Visible(false); + }) + @* ... *@ + ) + ##### Angular - - - + + + ##### Vue - ##### React - - import React from 'react'; - import 'devextreme/dist/css/dx.fluent.blue.light.css'; - - import { - DataGrid, - Column, - ColumnChooser - } from 'devextreme-react/data-grid'; + + import { DataGrid, ColumnChooser, Column } from 'devextreme-react/data-grid'; function App() { return ( -
- - {/* ... */} - - - -
+ + + + {/* ... */} + ); } - export default App; +--- + +Read Tutorial: Hide a Column Using the API ---- \ No newline at end of file +Read Tutorial: Column Chooser diff --git a/concepts/05 UI Components/DataGrid/00 Getting Started with DataGrid/20 Sort Data.md b/concepts/05 UI Components/DataGrid/00 Getting Started with DataGrid/20 Sort Data.md index 60bdfa9469..e1e1649ef6 100644 --- a/concepts/05 UI Components/DataGrid/00 Getting Started with DataGrid/20 Sort Data.md +++ b/concepts/05 UI Components/DataGrid/00 Getting Started with DataGrid/20 Sort Data.md @@ -1,102 +1,85 @@ -The **sorting**.[mode](/api-reference/10%20UI%20Components/GridBase/1%20Configuration/sorting/mode.md '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/sorting/#mode') property specifies whether users can sort grid records by single or multiple columns. This tutorial uses the default sorting mode - single. +The **sorting**.[mode](/api-reference/10%20UI%20Components/GridBase/1%20Configuration/sorting/mode.md '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/sorting/#mode') property specifies whether users can sort grid records by single or multiple columns. -You can also set a column's [sortOrder](/api-reference/_hidden/GridBaseColumn/sortOrder.md '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/columns/#sortOrder') and [sortIndex](/api-reference/_hidden/GridBaseColumn/sortIndex.md '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/columns/#sortIndex') properties to specify the initial sorting settings. [sortIndex](/api-reference/_hidden/GridBaseColumn/sortIndex.md '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/columns/#sortIndex') applies only in multiple sorting mode. +You can also set a column's [sortOrder](/api-reference/_hidden/GridBaseColumn/sortOrder.md '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/columns/#sortOrder') and [sortIndex](/api-reference/_hidden/GridBaseColumn/sortIndex.md '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/columns/#sortIndex') properties to specify initial sorting settings. [sortIndex](/api-reference/_hidden/GridBaseColumn/sortIndex.md '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/columns/#sortIndex') applies only in multiple sorting mode. + +To sort data and change sort orders in the UI, click column headers. Hold **Shift** and click to add sorting by other columns in multiple sorting mode. --- ##### jQuery - $(function() { - $("#dataGrid").dxDataGrid({ - // ... - columns: [{ - dataField: "Country", - sortOrder: "asc", - }, - // ... - ], - // sorting: { mode: "single" }, - }); + $("#dataGrid").dxDataGrid({ + sorting: { mode: "multiple" }, + columns: [{ + dataField: "Country", + sortOrder: "asc", + }, /* ... */ ], + // ... }); +##### ASP.NET Core Controls + + + @(Html.DevExtreme().DataGrid() + .Sorting(s => s.Mode(GridSortingMode.Multiple)) + .Columns(columns => { + columns.AddFor(m => m.Country) + .SortOrder(SortOrder.Asc); + }) + @* ... *@ + ) + ##### Angular - - + + - - + sortOrder="asc" + > + ##### Vue - ##### React - - import React from 'react'; - import 'devextreme/dist/css/dx.fluent.blue.light.css'; - - import { - DataGrid, - Column, - // ... - // Sorting - } from 'devextreme-react/data-grid'; + + import { DataGrid, Sorting, Column } from 'devextreme-react/data-grid'; function App() { return (
- {/* ... */} + - - {/* */} + sortOrder="asc" + /> + {/* ... */}
); } - export default App; - - --- -Run the code and ensure that grid records are sorted by the `Country` column. Click a column header to sort the records by another column. \ No newline at end of file +Read Tutorial: DataGrid - Sorting diff --git a/concepts/05 UI Components/DataGrid/00 Getting Started with DataGrid/30 Filter and Search Data.md b/concepts/05 UI Components/DataGrid/00 Getting Started with DataGrid/30 Filter and Search Data.md index 98d76e8321..8cb29f8ed3 100644 --- a/concepts/05 UI Components/DataGrid/00 Getting Started with DataGrid/30 Filter and Search Data.md +++ b/concepts/05 UI Components/DataGrid/00 Getting Started with DataGrid/30 Filter and Search Data.md @@ -1,92 +1,71 @@ -The DataGrid includes the following UI elements used to filter and search data: +DataGrid includes the following UI elements used to filter and search data: - [filterRow](/api-reference/10%20UI%20Components/GridBase/1%20Configuration/filterRow '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/filterRow/') - [headerFilter](/api-reference/_hidden/GridBaseColumn/headerFilter '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/columns/headerFilter/') - [filterPanel](/api-reference/10%20UI%20Components/GridBase/1%20Configuration/filterPanel '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/filterPanel/') with [filterBuilder](/api-reference/10%20UI%20Components/GridBase/1%20Configuration/filterBuilder.md '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/#filterBuilder') - [searchPanel](/api-reference/10%20UI%20Components/GridBase/1%20Configuration/searchPanel '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/searchPanel/') -In this tutorial, the [filterRow](/api-reference/10%20UI%20Components/GridBase/1%20Configuration/filterRow '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/filterRow/') and [searchPanel](/api-reference/10%20UI%20Components/GridBase/1%20Configuration/searchPanel '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/searchPanel/') are displayed: +This tutorial uses the [filterRow](/api-reference/10%20UI%20Components/GridBase/1%20Configuration/filterRow '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/filterRow/') and [searchPanel](/api-reference/10%20UI%20Components/GridBase/1%20Configuration/searchPanel '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/searchPanel/'): --- ##### jQuery - $(function() { - $("#dataGrid").dxDataGrid({ - // ... - filterRow: { visible: true }, - searchPanel: { visible: true }, - }); + $("#dataGrid").dxDataGrid({ + filterRow: { visible: true }, + searchPanel: { visible: true }, + // ... }); +##### ASP.NET Core Controls + + + @(Html.DevExtreme().DataGrid() + .FilterRow(f => f.Visible(true)) + .SearchPanel(s => s.Visible(true)) + @* ... *@ + ) + ##### Angular - - + + ##### Vue - ##### React - - import React from 'react'; - import 'devextreme/dist/css/dx.fluent.blue.light.css'; - - import { - DataGrid, - // ... - FilterRow, - SearchPanel - } from 'devextreme-react/data-grid'; + + import { DataGrid, FilterRow, SearchPanel } from 'devextreme-react/data-grid'; function App() { return ( -
- - {/* ... */} - - - -
+ + + + {/* ... */} + ); } - export default App; - --- -Run the code and enter a value in a filter row cell or the search panel. Grid data is filtered according to this value. \ No newline at end of file +Read Tutorial: DataGrid - Filtering and Searching diff --git a/concepts/05 UI Components/DataGrid/00 Getting Started with DataGrid/35 Group Data.md b/concepts/05 UI Components/DataGrid/00 Getting Started with DataGrid/35 Group Data.md index 8e51813728..290dd07b3e 100644 --- a/concepts/05 UI Components/DataGrid/00 Getting Started with DataGrid/35 Group Data.md +++ b/concepts/05 UI Components/DataGrid/00 Getting Started with DataGrid/35 Group Data.md @@ -1,106 +1,81 @@ -Grid records can be grouped by single or multiple columns. To group records, users should drag and drop column headers onto the [groupPanel](/api-reference/10%20UI%20Components/dxDataGrid/1%20Configuration/groupPanel '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/groupPanel/'). Enable the **groupPanel**.[visible](/api-reference/10%20UI%20Components/dxDataGrid/1%20Configuration/groupPanel/visible.md '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/groupPanel/#visible') property to display this UI element. +You can group DataGrid records by single or multiple columns. To group records in the UI, you can right-click column headers if **grouping**.[contextMenuEnabled](/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/grouping/#contextMenuEnabled) is `true` (default). You can also drag and drop column headers onto the group panel if **groupPanel**.[visible](/api-reference/10%20UI%20Components/dxDataGrid/1%20Configuration/groupPanel/visible.md '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/groupPanel/#visible') is `true`. -To group data in code, specify a column's [groupIndex](/api-reference/_hidden/dxDataGridColumn/groupIndex.md '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/columns/#groupIndex') property. In this tutorial, the [groupIndex](/api-reference/_hidden/dxDataGridColumn/groupIndex.md '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/columns/#groupIndex') is specified for the `Country` column: +To group data in code, define **columns[]**.[groupIndex](/api-reference/_hidden/dxDataGridColumn/groupIndex.md '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/columns/#groupIndex') property. This tutorial specifies **groupIndex** for the `Country` column: --- ##### jQuery - $(function() { - $("#dataGrid").dxDataGrid({ - columns: [ - // ... - { - dataField: "Country", - // ... - groupIndex: 0, - }, - // ... - ], - groupPanel: { visible: true }, - }); + $("#dataGrid").dxDataGrid({ + groupPanel: { visible: true }, + columns: [{ + dataField: "Country", + groupIndex: 0, + }, /* ... */ ], + // ... }); +##### ASP.NET Core Controls + + + @(Html.DevExtreme().DataGrid() + .GroupPanel(p => p.Visible(true)) + .Columns(columns => { + columns.AddFor(m => m.Country) + .GroupIndex(0); + }) + @* ... *@ + ) + ##### Angular - - + + - - + [groupIndex]="0" + > + ##### Vue - ##### React - - import React from 'react'; - import 'devextreme/dist/css/dx.fluent.blue.light.css'; - - import { - DataGrid, - Column, - // ... - GroupPanel - } from 'devextreme-react/data-grid'; + + import { DataGrid, GroupPanel, Column } from 'devextreme-react/data-grid'; function App() { return ( -
- - {/* ... */} - - - - -
+ + + + {/* ... */} + ); } - export default App; - --- -If you run the code, records are grouped by the `Country` column. This column's header is on the group panel. Drag and drop column headers to and from the group panel to change the grouping. +Read Tutorial: DataGrid - Grouping diff --git a/concepts/05 UI Components/DataGrid/00 Getting Started with DataGrid/40 Edit and Validate Data.md b/concepts/05 UI Components/DataGrid/00 Getting Started with DataGrid/40 Edit and Validate Data.md index 740b792354..8e524dcc0b 100644 --- a/concepts/05 UI Components/DataGrid/00 Getting Started with DataGrid/40 Edit and Validate Data.md +++ b/concepts/05 UI Components/DataGrid/00 Getting Started with DataGrid/40 Edit and Validate Data.md @@ -1,189 +1,170 @@ -Users can add new records and update or delete existing records. To allow these operations, enable the [allowAdding](/api-reference/10%20UI%20Components/dxDataGrid/1%20Configuration/editing/allowAdding.md '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/editing/#allowAdding'), [allowUpdating](/api-reference/10%20UI%20Components/dxDataGrid/1%20Configuration/editing/allowUpdating.md '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/editing/#allowUpdating'), and [allowDeleting](/api-reference/10%20UI%20Components/dxDataGrid/1%20Configuration/editing/allowDeleting.md '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/editing/#allowDeleting') properties in the [editing](/api-reference/10%20UI%20Components/dxDataGrid/1%20Configuration/editing '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/editing/') object. Multiple [edit modes](/api-reference/10%20UI%20Components/dxDataGrid/1%20Configuration/editing/mode.md '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/editing/#mode') are available. This tutorial uses the pop-up edit mode. +Users can add new records and update or delete existing records. To allow these operations, enable the following [editing](/api-reference/10%20UI%20Components/dxDataGrid/1%20Configuration/editing '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/editing/') options: -DevExtreme includes a validation engine that checks edited values before they are saved. This engine supports different validation rule types, such as [Email](/api-reference/10%20UI%20Components/dxValidator/8%20Validation%20Rules/EmailRule '/Documentation/ApiReference/UI_Components/dxValidator/Validation_Rules/EmailRule/'), [Compare](/api-reference/10%20UI%20Components/dxValidator/8%20Validation%20Rules/CompareRule '/Documentation/ApiReference/UI_Components/dxValidator/Validation_Rules/CompareRule/'), [Range](/api-reference/10%20UI%20Components/dxValidator/8%20Validation%20Rules/RangeRule '/Documentation/ApiReference/UI_Components/dxValidator/Validation_Rules/RangeRule/'), and more. Validation rules are specified per column; one column can use multiple rules. The code below assigns the [Required](/api-reference/10%20UI%20Components/dxValidator/8%20Validation%20Rules/RequiredRule '/Documentation/ApiReference/UI_Components/dxValidator/Validation_Rules/RequiredRule/') rule to several columns. +- [allowAdding](/api-reference/10%20UI%20Components/dxDataGrid/1%20Configuration/editing/allowAdding.md '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/editing/#allowAdding') +- [allowUpdating](/api-reference/10%20UI%20Components/dxDataGrid/1%20Configuration/editing/allowUpdating.md '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/editing/#allowUpdating') +- [allowDeleting](/api-reference/10%20UI%20Components/dxDataGrid/1%20Configuration/editing/allowDeleting.md '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/editing/#allowDeleting') + +DataGrid includes multiple [edit modes](/api-reference/10%20UI%20Components/dxDataGrid/1%20Configuration/editing/mode.md '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/editing/#mode'). This tutorial uses the pop-up edit mode. + +This tutorial also implements [data validation](/Documentation/Guide/UI_Components/Common/UI_Widgets/Data_Validation/) to check that edited data is valid before saving. [Required](/api-reference/10%20UI%20Components/dxValidator/8%20Validation%20Rules/RequiredRule '/Documentation/ApiReference/UI_Components/dxValidator/Validation_Rules/RequiredRule/') rules are configured to ensure certain column values are never empty: --- ##### jQuery - $(function() { - $("#dataGrid").dxDataGrid({ - editing: { - mode: "popup", - allowUpdating: true, - allowDeleting: true, - allowAdding: true - }, - columns: [{ - dataField: "FullName", - validationRules: [{ type: "required" }] - }, { - dataField: "Position", - validationRules: [{ type: "required" }] - }, { - dataField: "BirthDate", - // ... - validationRules: [{ type: "required" }] - }, { - dataField: "HireDate", - // ... - validationRules: [{ type: "required" }] - }, - // ... - { - dataField: "Country", - // ... - validationRules: [{ type: "required" }] - }, - // ... - ], - }); + $("#dataGrid").dxDataGrid({ + editing: { + mode: "popup", + allowUpdating: true, + allowDeleting: true, + allowAdding: true + }, + columns: [{ + dataField: "FullName", + validationRules: [{ type: "required" }] + }, { + dataField: "Position", + validationRules: [{ type: "required" }] + }, { + dataField: "BirthDate", + validationRules: [{ type: "required" }] + }, { + dataField: "HireDate", + validationRules: [{ type: "required" }] + }, { + dataField: "Country", + validationRules: [{ type: "required" }] + }, /* ... */ ], + // ... }); +##### ASP.NET Core Controls + + + @(Html.DevExtreme().DataGrid() + .Editing(e => e + .Mode(GridEditMode.Popup) + .AllowAdding(true) + .AllowDeleting(true) + .AllowUpdating(true) + ) + .Columns(columns => { + columns.AddFor(m => m.FullName) + .ValidationRules(v => v.AddRequired()); + columns.AddFor(m => m.Position) + .ValidationRules(v => v.AddRequired()); + columns.AddFor(m => m.BirthDate) + .ValidationRules(v => v.AddRequired()); + columns.AddFor(m => m.HireDate) + .ValidationRules(v => v.AddRequired()); + columns.AddFor(m => m.Country) + .ValidationRules(v => v.AddRequired()); + }) + @* ... *@ + ) + ##### Angular - - + + - + - + - + - - + ##### Vue - ##### React - - import React from 'react'; - import 'devextreme/dist/css/dx.fluent.blue.light.css'; - - import { - DataGrid, - Column, - // ... - RequiredRule, - Editing - } from 'devextreme-react/data-grid'; + + import { DataGrid, Editing, Column, RequiredRule } from 'devextreme-react/data-grid'; function App() { return ( -
- - {/* ... */} - - - - - - - - - - - - - {/* ... */} - - - - - -
+ + + + + + + + + + + + + + + + + + {/* ... */} + ); } - export default App; - --- -Run the code and click the Edit button in any row. This invokes a pop-up window that contains an edit form. When you clear the Full Name text box on this form, the following validation error is shown: *"Full Name is required"*. +Read Tutorial: DataGrid - Editing -To learn how to validate unchanged cells with a button click, refer to the following example: +To implement validation for unchanged cells using a custom toolbar button, refer to the following example: #include btn-open-github with { href: "https://github.com/DevExpress-Examples/devextreme-data-grid-validate-unchanged-cells" diff --git a/concepts/05 UI Components/DataGrid/00 Getting Started with DataGrid/50 Select Records.md b/concepts/05 UI Components/DataGrid/00 Getting Started with DataGrid/50 Select Records.md index a9469b33b3..da70a3128b 100644 --- a/concepts/05 UI Components/DataGrid/00 Getting Started with DataGrid/50 Select Records.md +++ b/concepts/05 UI Components/DataGrid/00 Getting Started with DataGrid/50 Select Records.md @@ -1,23 +1,21 @@ -The DataGrid supports single and multiple record selection modes. Use the **selection**.[mode](/api-reference/10%20UI%20Components/GridBase/1%20Configuration/selection/mode.md '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/selection/#mode') property to specify the mode. +DataGrid supports single and multiple selection. To enable this capability, configure the **selection**.[mode](/api-reference/10%20UI%20Components/GridBase/1%20Configuration/selection/mode.md '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/selection/#mode') property. -You can obtain the selected record's data in the [onSelectionChanged](/api-reference/10%20UI%20Components/dxDataGrid/1%20Configuration/onSelectionChanged.md '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/#onSelectionChanged') function. In the code below, this function displays the selected employee under the DataGrid: +To obtain selected records at runtime, define [onSelectionChanged](/api-reference/10%20UI%20Components/dxDataGrid/1%20Configuration/onSelectionChanged.md '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/#onSelectionChanged'). This tutorial configures **onSelectionChanged** to display selected employee names in a `
` element outside of the component: --- ##### jQuery - $(function() { - $("#dataGrid").dxDataGrid({ - // ... - selection: { mode: "single" }, - onSelectionChanged: function(e) { - e.component.byKey(e.currentSelectedRowKeys[0]).done(employee => { - if(employee) { - $("#selected-employee").text(`Selected employee: ${employee.FullName}`); - } - }); - }, - }); + $("#dataGrid").dxDataGrid({ + selection: { mode: "single" }, + onSelectionChanged: function(e) { + e.component.byKey(e.currentSelectedRowKeys[0]).done(employee => { + if(employee) { + $("#selected-employee").text(`Selected employee: ${employee.FullName}`); + } + }); + }, + // ... }); @@ -31,52 +29,57 @@ You can obtain the selected record's data in the [onSelectionChanged](/api-refer - - /* ... */ - #app-container { - width: 900px; - position: relative; - } +##### ASP.NET Core Controls - #selected-employee { - position: absolute; - left: 50%; - transform: translate(-50%, 0); - } + +
+ @(Html.DevExtreme().DataGrid() + .Selection(s => s.Mode(SelectionMode.Single)) + .OnSelectionChanged("handleSelectionChanged") + @* ... *@ + ) +

+
+ + ##### Angular
- - + + -

- Selected employee: {{ selectedEmployee.FullName }} -

+ @if (selectedEmployee) { +

+ Selected employee: {{ selectedEmployee.FullName }} +

+ }
import { Component } from '@angular/core'; + import { DxDataGridTypes } from 'devextreme-angular/ui/data-grid'; import { Employee, EmployeesService } from './employees.service'; - @Component({ - selector: 'app-root', - templateUrl: './app.component.html', - styleUrls: ['./app.component.css'] - }) + // ... export class AppComponent { - // ... selectedEmployee: Employee; constructor(service: EmployeesService) { - // ... this.selectEmployee = this.selectEmployee.bind(this); } - selectEmployee(e) { + selectEmployee(e: DxDataGridTypes.SelectionChangedEvent) { e.component.byKey(e.currentSelectedRowKeys[0]).done(employee => { if(employee) { this.selectedEmployee = employee; @@ -85,28 +88,14 @@ You can obtain the selected record's data in the [onSelectionChanged](/api-refer } } - - /* ... */ - #app-container { - width: 900px; - position: relative; - } - - #selected-employee { - position: absolute; - left: 50%; - transform: translate(-50%, 0); - } - ##### Vue - + ##### React - + import React, { useCallback, useState } from 'react'; - import 'devextreme/dist/css/dx.fluent.blue.light.css'; - import './App.css'; - - import { - DataGrid, - Column, - // ... - Selection - } from 'devextreme-react/data-grid'; + import { DataGrid, Selection, type DataGridTypes } from 'devextreme-react/data-grid'; + import { type Employee } from './employees'; function SelectedEmployee(props) { if(props.employee) { @@ -186,37 +139,23 @@ You can obtain the selected record's data in the [onSelectionChanged](/api-refer function App() { const [selectedEmployee, setSelectedEmployee] = useState(); - const selectEmployee = useCallback((e) => { - e.component.byKey(e.currentSelectedRowKeys[0]).done(employee => { + const selectEmployee = useCallback((e: DataGridTypes.SelectionChangedEvent): void => { + e.component.byKey(e.currentSelectedRowKeys[0]).then((employee: Employee) => { setSelectedEmployee(employee); - }); + }).catch(() => {}); }, []); return (
- - {/* ... */} + + {/* ... */}
); } - export default App; - - - /* ... */ - .App { - width: 900px; - position: relative; - } - - #selected-employee { - position: absolute; - left: 50%; - transform: translate(-50%, 0); - } +--- ---- \ No newline at end of file +Read Tutorial: DataGrid - Selection diff --git a/concepts/05 UI Components/DataGrid/00 Getting Started with DataGrid/60 Display Summaries.md b/concepts/05 UI Components/DataGrid/00 Getting Started with DataGrid/60 Display Summaries.md index 785e177571..b1fddd5dcf 100644 --- a/concepts/05 UI Components/DataGrid/00 Getting Started with DataGrid/60 Display Summaries.md +++ b/concepts/05 UI Components/DataGrid/00 Getting Started with DataGrid/60 Display Summaries.md @@ -1,109 +1,84 @@ -Summaries can be divided into two groups: +DataGrid supports two types of data summaries: -- **Total summaries** -Calculated against all grid records; configured in the [totalItems](/api-reference/10%20UI%20Components/dxDataGrid/1%20Configuration/summary/totalItems '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/summary/totalItems/') array. +- **Total summaries**: Calculated against all grid records. Configured in the [totalItems](/api-reference/10%20UI%20Components/dxDataGrid/1%20Configuration/summary/totalItems '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/summary/totalItems/') array. +- **Group summaries**: Calculated for each data group. Configured in the [groupItems](/api-reference/10%20UI%20Components/dxDataGrid/1%20Configuration/summary/groupItems '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/summary/groupItems/') array. -- **Group summaries** -Calculated for each data group; configured in the [groupItems](/api-reference/10%20UI%20Components/dxDataGrid/1%20Configuration/summary/groupItems '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/summary/groupItems/') array. - -Each summary item displays a value that is the result of applying an aggregate function to data. You can use [predefined aggregate functions](/concepts/05%20UI%20Components/DataGrid/65%20Summaries/05%20Predefined%20Aggregate%20Functions.md '/Documentation/Guide/UI_Components/DataGrid/Summaries/Predefined_Aggregate_Functions/'), such as *"sum"*, *"avg"*, and *"count"*, or implement a [custom aggregate function](/concepts/05%20UI%20Components/DataGrid/65%20Summaries/07%20Custom%20Aggregate%20Function '/Documentation/Guide/UI_Components/DataGrid/Summaries/Custom_Aggregate_Function/'). To apply an aggregate function, set the [summaryType](/api-reference/10%20UI%20Components/dxDataGrid/1%20Configuration/summary/totalItems/summaryType.md '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/summary/totalItems/#summaryType') property. - -The code below configures a group summary that counts grid records in each group: +Each summary item applies an aggregate function specified in [summaryType](/api-reference/10%20UI%20Components/dxDataGrid/1%20Configuration/summary/totalItems/summaryType.md '/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/summary/totalItems/#summaryType') to display summarized values. You can use [predefined aggregate functions](/concepts/05%20UI%20Components/DataGrid/65%20Summaries/05%20Predefined%20Aggregate%20Functions.md '/Documentation/Guide/UI_Components/DataGrid/Summaries/Predefined_Aggregate_Functions/') (such as *"sum"*, *"avg"*, and *"count"*) or define a [custom aggregate function](/concepts/05%20UI%20Components/DataGrid/65%20Summaries/07%20Custom%20Aggregate%20Function '/Documentation/Guide/UI_Components/DataGrid/Summaries/Custom_Aggregate_Function/'). This tutorial implements a *"count"* group summary: --- ##### jQuery - $(function() { - $("#dataGrid").dxDataGrid({ - // ... - summary: { - groupItems: [{ - summaryType: "count" - }] - }, - }); + $("#dataGrid").dxDataGrid({ + summary: { + groupItems: [{ + summaryType: "count" + }] + }, + // ... }); +##### ASP.NET Core Controls + + + @(Html.DevExtreme().DataGrid() + .Summary(s => s + .GroupItems(groupItems => { + groupItems.Add().SummaryType(SummaryType.Count); + }) + ) + @* ... *@ + ) + ##### Angular - - + + ##### Vue - ##### React - - import React, { useState } from 'react'; - import 'devextreme/dist/css/dx.fluent.blue.light.css'; - import './App.css'; - - import { - DataGrid, - Column, - // ... - Summary, - GroupItem - } from 'devextreme-react/data-grid'; + + import { DataGrid, Summary, GroupItem } from 'devextreme-react/data-grid'; - // ... function App() { - // ... return (
- - {/* ... */} + - + + {/* ... */}
); } - export default App; +--- + +Read Tutorial: DataGrid - Total Summary ---- \ No newline at end of file +Read Tutorial: DataGrid - Group Summary diff --git a/concepts/05 UI Components/DataGrid/00 Getting Started with DataGrid/65 Customize the Toolbar.md b/concepts/05 UI Components/DataGrid/00 Getting Started with DataGrid/65 Customize the Toolbar.md index 4d64a2853a..9d3f85d580 100644 --- a/concepts/05 UI Components/DataGrid/00 Getting Started with DataGrid/65 Customize the Toolbar.md +++ b/concepts/05 UI Components/DataGrid/00 Getting Started with DataGrid/65 Customize the Toolbar.md @@ -6,69 +6,87 @@ ##### jQuery - $(function() { - const dataGrid = $("#dataGrid").dxDataGrid({ - // ... - toolbar: { - items: [ - "groupPanel", - { - location: "after", - widget: "dxButton", - options: { - text: "Collapse All", - width: 136, - onClick(e) { - const expanding = e.component.option("text") === "Expand All"; - dataGrid.option("grouping.autoExpandAll", expanding); - e.component.option("text", expanding ? "Collapse All" : "Expand All"); - }, + const dataGrid = $("#dataGrid").dxDataGrid({ + toolbar: { + items: [ + "groupPanel", { + location: "after", + widget: "dxButton", + options: { + text: "Collapse All", + width: 136, + onClick(e) { + const expanding = e.component.option("text") === "Expand All"; + dataGrid.option("grouping.autoExpandAll", expanding); + e.component.option("text", expanding ? "Collapse All" : "Expand All"); }, }, - { - name: "addRowButton", - showText: "always" - }, - "exportButton", - "columnChooserButton", - "searchPanel" - ] - }, - }).dxDataGrid("instance"); - }); + }, { + name: "addRowButton", + showText: "always" + }, "exportButton", "columnChooserButton", "searchPanel", + ] + }, + // ... + }).dxDataGrid("instance"); + +##### ASP.NET Core Controls + + + @(Html.DevExtreme().DataGrid() + .ID("grid-container") + .Toolbar(t => t.Items(items => { + items.Add().Name(DataGridToolbarItem.GroupPanel); + items.Add() + .Location(ToolbarItemLocation.After) + .Widget(w => w.Button() + .Text("Collapse All") + .Width(136) + .OnClick("handleCollapseAllButtonClick") + ); + items.Add().Name(DataGridToolbarItem.AddRowButton).ShowText(ToolbarItemShowTextMode.Always); + items.Add().Name(DataGridToolbarItem.ExportButton); + items.Add().Name(DataGridToolbarItem.ColumnChooserButton); + items.Add().Name(DataGridToolbarItem.SearchPanel); + })) + @* ... *@ + ) + + ##### Angular -
- - - - - - - - - - - - - - - -
+ + + + + + + + + + + + + + + // ... - @Component({ - // ... - }) export class AppComponent { // ... - expanded: Boolean = true; + expanded: boolean = true; } @@ -90,108 +108,65 @@ - + const expanded = ref(true); - + ##### React - - import React, { useState } from 'react'; - import 'devextreme/dist/css/dx.fluent.blue.light.css'; - import './App.css'; - - import { - DataGrid, - // ... - Grouping, - Toolbar, - Item - } from 'devextreme-react/data-grid'; + + import { DataGrid, Grouping, Toolbar, Item } from 'devextreme-react/data-grid'; import { Button } from 'devextreme-react/button'; - // ... - function App() { - // ... const [expanded, setExpanded] = useState(true); return ( -
- - {/* ... */} - - - - -
+ + + + + +