How to keep selected row although data source changes

Hi,


We have used the grid component by React.

I would like to wrapped row even when the data source in the grid component changes and rerender, and to keep the selection mark.

So, I want to confirm to have a callback function in APIs of the grid component, and If it haven't, I'd like to know how to keep selected row.


1 Reply

RS Rajapandiyan Settu Syncfusion Team July 5, 2022 01:16 PM UTC

Hi Sohyeonbak,


Thanks for Syncfusion support.


By default, the selection will be removed when we perform any data actions like Paging, Sorting, Filtering, refreshing, etc., in the Grid.


If ‘persistSelection’ is set to true, then the Grid selection is persisted on all the operations. For persisting selection in the Grid, any one of the columns should be enabled as a primary key. The primaryKey field should contain unique values in the dataSource.


The checkbox type column is mandatory for the persistSelection feature.


https://ej2.syncfusion.com/react/documentation/grid/selection/check-box-selection/

Sample: https://stackblitz.com/edit/react-k9yvwd?file=index.js


Note: All the selections are maintained based on the selected row’s primary key. So, if the changed dataSource does not contain the previously selected primary key, Grid does not maintain the selection.


Regards,

Rajapandiyan S


Loader.
Up arrow icon