Blazor DataGrid Example - Batch Editing
Order ID | Customer ID | Freight | Order Date | Ship Country |
|---|
| 10001 | ALFKI | $2.30 | 5/15/1991 | Denmark |
| 10002 | ANATR | $3.30 | 4/4/1990 | Brazil |
| 10003 | ANTON | $4.30 | 11/30/1957 | Germany |
| 10004 | BLONP | $5.30 | 10/22/1930 | Austria |
| 10005 | BOLID | $6.30 | 2/18/1953 | Switzerland |
| 10006 | ALFKI | $4.60 | 5/15/1991 | Denmark |
| 10007 | ANATR | $6.60 | 4/4/1990 | Brazil |
| 10008 | ANTON | $8.60 | 11/30/1957 | Germany |
| 10009 | BLONP | $10.60 | 10/22/1930 | Austria |
| 10010 | BOLID | $12.60 | 2/18/1953 | Switzerland |
| 10011 | ALFKI | $6.90 | 5/15/1991 | Denmark |
| 10012 | ANATR | $9.90 | 4/4/1990 | Brazil |
This sample demonstrates how to use batch editing mode in the DataGrid to perform CRUD operations efficiently.
The Blazor DataGrid batch editing feature enables you to start editing by double-clicking a cell and modifying its value. You can perform CRUD operations as follows:
- Add - Click the Add toolbar button to create a new record.
- Edit - Double-click a row or click the Edit toolbar button after selecting a row to modify data.
- Delete - Click the Delete toolbar button after selecting a row to remove a record.
- Update - Click the Update toolbar button to save all edited changes.
- Cancel - Click the Cancel toolbar button to discard all edited changes.
CRUD operations are configured in the DataGrid using the GridEditSettings component. You must define at least one column as a primary key using the IsPrimaryKey property in the GridColumn component.
The available edit modes are:
- Inline - Edit records directly within the grid rows
- Dialog - Edit records in a modal dialog
By default, new rows are added at the top of the DataGrid. You can change this behavior by setting the NewRowPosition property to Batch in GridEditSettings.
In this demo, batch mode is enabled by setting the Mode property to Batch in the GridEditSettings component. Begin editing by double-clicking a cell and changing its value. When navigating to a new cell, the edited cell is highlighted to indicate which cells have been modified. Bulk save all edited data to the datasource by clicking the Update button on the toolbar.
For more detailed information about batch editing, refer to the batch editing documentation.