We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to get dataSource after filtering, sorting

Hi Syncfusion team,
I'm using Grid component and I have a need is get all data grid after filtering, sorting.

Example:

Expected: get all data showed on Grid (image)
Link: https://stackblitz.com/edit/react-ta71qb?file=index.js
Are there any way to reach my requirement?

Thanks.


13 Replies 1 reply marked as answer

JC Joseph Christ Nithin Issack Syncfusion Team February 24, 2023 10:47 AM UTC


Hi Ton,


  Greetings from Syncfusion support.


  Based on your query, you want to get the filtered records. Your requirements can be achieved by calling the getFilteredRecords method of the EJ2 Grid.


  Documentation: https://helpej2.syncfusion.com/react/documentation/api/grid/#getfilteredrecords


Regards,

Joseph I.



TT Ton That Hung February 24, 2023 11:39 AM UTC

Hi Joseph,


Seem like if I don't filter in grid, getFilteredRecords ​will return empty array.

Are you have the way to control this problems?

Thanks.



JC Joseph Christ Nithin Issack Syncfusion Team February 27, 2023 01:58 PM UTC

Ton,


  Before proceeding with the solution, we would like you to share the below details.


  • Complete grid rendering code.
  • Details on where you have used the `getFilteredRecords` method.
  • Video demo of your requirement.




TT Ton That Hung March 1, 2023 03:03 AM UTC

Hi Joseph,

In my example: I have the getDataSource button, if you click on this button, the console will show the dataSource.
If I have filtered, the console would be shown true.
But If I haven't filtered, the console only show empty array.

Link: https://stackblitz.com/edit/react-ta71qb-35neud?file=index.js

Didn't filter + sorted: