Example of Custom Binding in Blazor DataGrid Component
This sample shows how to use custom data binding in the DataGrid component.
Order ID | Customer ID | Freight | Order Date | Ship Name | Ship Country |
---|
No records to display |
The Blazor DataGrid custom data binding can be performed by providing the custom adaptor class and overriding the DataAdaptor abstract class's Read or ReadAsync method
The custom adaptor class must be added as service using AddScoped/AddSingleton method in the Startup.cs. Using the Inject attribute on a specific property, you can inject your own services or DB context into a custom adaptor class.
The CRUD operations for the custom data binding in the DataGrid component can be implemented by overriding the DataAdaptor abstract class's CRUD methods, which are listed below.
- Insert/InsertAsync - Performs Insert operation.
- Remove/RemoveAsync - Performs Remove operation.
- Update/UpdateAsync - Performs Update operation.
- BatchUpdate/BatchUpdateAsync - Performs BatchUpdate operation.
In this demo, CRUD operations for the custom data binding are performed using the DataAdaptor abstract class's methods. Similarly, you can use the BatchUpdate/BatchUpdateAsync methods to perform Batch Update operations.
More information about the Custom data binding feature can be found in this documentation section.