inovua / reactdatagrid

Empower Your Data with the best React Data Grid there is
https://reactdatagrid.io
Other
3.45k stars 57 forks source link

Provide callback to get filtered data #340

Open AndrewBoklashko opened 1 year ago

AndrewBoklashko commented 1 year ago

I am implementing a feature similar to CSV export, as described in docs. The issue is that I need to disable "Export CSV" button when data grid has no displayed data, can be when user filters did not match any record. With suggested approach this is not possible, because gridRef.current.data is not reactive.

My suggestion is to have a callback prop: onDisplayDataChange(data: any[]), which will provide same data as gridRef.current.data. This way developers can operate with the actual data, displayed on the grid in a reactive manner. Also code will be cleaner, because ref will no longer be required.

Somewhat related issue, developer is doing a combination of filter function and onFilterValueChange to get filtered rows. But this will approach with not work with remote dataSource.

Thanks in advance!

AndrewBoklashko commented 1 year ago

Just found that I can use filteredRowsCount callback to solve my problem. Still think that having onDisplayDataChange prop would be useful for other scenarios and for better developer's experience. However feel free to close this issue if you consider it's not worth it.

AndrewBoklashko commented 10 months ago

Any updates?