reactdatagrid icon indicating copy to clipboard operation
reactdatagrid copied to clipboard

How to get all filtered data with gridRef when there is pagination?

Open noelfloresr opened this issue 2 years ago • 1 comments

Hi,

In your example https://reactdatagrid.io/docs/miscellaneous#csv-export-+-custom-search-box it only gets the visual data (current page), but how to get the data of all pages? I know that dataSource has all records, but not the filtered ones. May you help me? Thanks.

noelfloresr avatar Nov 15 '22 13:11 noelfloresr

We would definitely like to have a gridRef.current.filteredData prop available through the API, which would let us programmatically do things to all the filtered rows in the grid even when paging is active. Whether that be exporting to Excel, or mass-editing a value in those rows without doing it to the rows that are filtered out. You can do this now if paging is disabled, but it will only return the filtered data for 1 page if it is enabled.

Our current solution is:

  • set the limit equal to the max # of rows in data
  • do a 50ms timeout so that React renders the datagrid again
  • run a callback function in that timeout that does the necessary actions we need to do on all filtered rows
  • and finally reset the limit back to the initial value

smitty3268 avatar Feb 28 '23 17:02 smitty3268