Select a set of records dynamically in a paged grid

Hello, I have a grid with several hundred records over several pages. I want to select some of these records dynamically on load based on a custom condition, and persist that selection when the page is changed. My selection settings are {type: "Multiple", checkboxOnly: true, persistSelection: true}.

I know how to read the selection and how to handle the rowSelected / rowUnselected events, so the only problem left is selecting the items dynamically.

I've tried calling the selectRows method with the indexes of the items to select, but this only works for the currently visible page. How can I select rows when some of the items to be selected are on pages that are not currently visible?


5 Replies 1 reply marked as answer

PG Praveenkumar Gajendiran Syncfusion Team May 27, 2021 06:14 AM UTC

Hi Ian,

Greetings from Syncfusion support.

We checked your query and we understood that you want to select a row (which is currently not visible on this page) by passing rowIndex through the selectRow method of Grid when pagination is enabled in the Grid. For this, we would like to inform you that by default when pagination is enabled in the Grid, the row indexes are generated based on the current page records. The grid will not calculate and generate the row indexes for the other page records and also not for the whole grid rows when pagination is enabled. This is our default behavior.

Please get back to us if you need further assistance with this.

Regards,
Praveenkumar G 



IS Ian Sanders May 28, 2021 03:18 PM UTC

I would like to select rows that are not currently visible on the page using some method, but it does not need to be the rowIndex method. I understand that the index way won't work with paging. Is there any other way to accomplish this task?



PG Praveenkumar Gajendiran Syncfusion Team May 31, 2021 10:57 AM UTC

Hi Ian,

Thanks for your update.

By default, If you enable Pagination in the Grid, only current set of row elements(based on your pageSize , default pageSize as 12) will be rendered in the DOM and next set of row elements will be rendered while go to the next page, So here we cannot access/select the another set of row elements which are in the next pages. This is our current grid architecture.

Please get back to us if you need further assistance.

Regards,
Praveenkumar G 



IS Ian Sanders June 1, 2021 04:47 PM UTC

Could you add this feature? You are able to persist selection across pages using the persistSelection option, so all I'm looking for is a way to update the persisted selection.


PG Praveenkumar Gajendiran Syncfusion Team June 2, 2021 01:43 PM UTC

Hi Ian,

As we informed, By default, If you enable Pagination in the Grid, only current set of row elements(based on your pageSize , default pageSize as 12) will be rendered in the DOM and next set of row elements will be rendered while go to the next page, So here we cannot access/select the another set of row elements which are not in the current page. This is our current grid architecture.

So please share us the below information that will be helpful to validate further on your requirement,  
1)                 Let us know, do you have any customized method or key to find out the rows which are not on the currently visible page? if yes, please share the details about this.   
2)                 If you don’t have any method , then how to find the rowIndex when page is not available , please explain requirement and sample data what you bound to the Grid. 
 
3)                 Do you want to auto-select the row(which are in the other pages) when you navigate to that page or you want to select the rows in all the pages based on the condition initially.  
4)                 Do you bind local or remote data for Grid dataSource? Share the Grid code example. 
 

Regards,
Praveenkumar G 


Marked as answer
Loader.
Up arrow icon