Edit Modes
The Data Grid allows users to add, edit, and remove data rows.
- Add DxDataGridCommandColumn to the Data Grid. This column displays the New, Edit, and Delete command buttons. To hide unnecessary buttons, use the NewButtonVisible, EditButtonVisible, and DeleteButtonVisible properties.
-
Handle the following events to post changes to an underlying data source:
- RowInserting/RowInsertingAsync - Fires when a user adds a new row.
- RowUpdating/RowUpdatingAsync - Fires when a user updates a data row.
- RowRemoving/RowRemovingAsync - Fires when a user deletes a data row.
- Handle the InitNewRow event to initialize new data rows.
- Specify the key data field to enable the Data Grid to identify individual data items.
The Data Grid supports different edit modes. Use the Edit Mode option below (corresponds to the EditMode property) to switch between available modes.
- DataGridEditMode.EditForm (Default) – The Data Grid displays the edit form instead of the edited row.
- DataGridEditMode.PopupEditForm – The Data Grid displays the edit form in a pop-up window.
When a user clicks New or Edit, the Data Grid displays the Edit Form. This form consists of data editors for each visible column. The editor type depends on the corresponding column's type.
A Datum Corporation | Novelty Goods Supplier | Road Freight | (847) 555-0100 | Woodgrove Bank Zionsville | 8575824136 | |
Contoso, Ltd. | Novelty Goods Supplier | Refrigerated Road Freight | (360) 555-0100 | Woodgrove Bank Greenbank | 4587965215 | |
Consolidated Messenger | Courier Services Supplier | (415) 555-0100 | Woodgrove Bank San Francisco | 3254872158 | ||
Fabrikam, Inc. | Clothing Supplier | Road Freight | (203) 555-0104 | Woodgrove Bank Lakeview Heights | 4125863879 | |
Graphic Design Institute | Novelty Goods Supplier | Refrigerated Air Freight | (406) 555-0105 | Woodgrove Bank Lanagan | 1025869354 | |
Humongous Insurance | Insurance Services Supplier | (423) 555-0105 | Woodgrove Bank Lancing | 2569874521 | ||
Litware, Inc. | Packaging Supplier | Courier | (209) 555-0108 | Woodgrove Bank Mokelumne Hill | 3256896325 | |
Lucerne Publishing | Novelty Goods Supplier | Refrigerated Air Freight | (423) 555-0103 | Woodgrove Bank Jonesborough | 3254123658 | |
Nod Publishers | Novelty Goods Supplier | Refrigerated Air Freight | (252) 555-0100 | Woodgrove Bank Elizabeth City | 2021545878 | |
Northwind Electric Cars | Toy Supplier | Air Freight | (201) 555-0105 | Woodgrove Bank Crandon Lakes | 3258786987 | |
Trey Research | Marketing Services Supplier | (605) 555-0103 | Woodgrove Bank Kadoka | 1254785321 | ||
The Phone Company | Novelty Goods Supplier | Road Freight | (218) 555-0105 | Woodgrove Bank Karlstad | 7896236589 | |
Woodgrove Bank | Financial Services Supplier | (415) 555-0103 | Woodgrove Bank San Francisco | 2147825698 |
Cascading Editors
This module illustrates cascade comboboxes: City and Region. These comboboxes are displayed when you edit a grid row. The City combobox is dynamically populated with city names based on the value selected in the Region combobox.
Both the Region and City columns use the EditTemplate context cast to the CellEditContext type that contains:
- An original cell value as a DataItem object.
- An EditedValues dictionary with changed cell values.
- A CellValue object that stores the current cell’s value.
- Two overloads of the OnChanged method that allow one combobox to respond to another combobox’s value change.
- The GetEditorValue method that returns a value of any grid cell.
Click Edit to see how the Region and City comboboxes communicate using the OnChanged and GetEditorValue methods to pass/get values to/from each other.