DataGrid Checkbox selection persistence to a database

Is it possible to override the persistence to localstorage for the checkbox selection method of the DataGrid. I'd like to bind it to a field in the datasource instead. 

1 Reply 1 reply marked as answer

RS Renjith Singh Rajendran Syncfusion Team May 14, 2021 07:19 AM UTC

Hi Michael, 

Greetings from Syncfusion support. 

We have support for persisting selection in grid. Please refer the notes section of below documentation for more details, 

And to update the Field value based on selection, we suggest you to bind RowSelected/RowDeselected event to Grid and use UpdateRow method to update the corresponding column. We have prepared a sample, in which we will be updating the IsSelected Field based on the selection in row. 
References :  
 
Please refer the codes below, 

<GridSelectionSettings Type="SelectionType.Multiple" PersistSelection="true"></GridSelectionSettings><GridEvents RowSelected="RowSelected" RowDeselected="RowDeselected" TValue="Order"></GridEvents>
 
SfGrid<Order> Grid; 
public async Task RowSelected(RowSelectEventArgs<Order> args) 
{ 
    args.Data.IsSelected = true; 
    await Grid.UpdateRow(args.RowIndex, args.Data); 
} 
public async Task RowDeselected(RowDeselectEventArgs<Order> args) 
{ 
    args.Data.IsSelected = false; 
    await Grid.UpdateRow(args.RowIndex, args.Data); 
} 


Please get back to us if you need further assistance. 

Regards, 
Renjith R 


Marked as answer
Loader.
Up arrow icon