glide-data-grid icon indicating copy to clipboard operation
glide-data-grid copied to clipboard

Row filtering

Open kevinlovescoffee opened this issue 1 year ago • 5 comments

We are currently filtering rows by adding a hidden property to rows that we want to hide. In the rowHeight prop we set the hidden row's height to 0. So, something like: rowHeight={(index) => (data[index]?.hidden ? 0 : 34)}. This produces the result that we want, but we noticed with larger data sets (around 25,000) rows there are performance issues. Is there are a better way to go about filtering rows? If not, it would be amazing to have this functionality!

kevinlovescoffee avatar Oct 19 '24 04:10 kevinlovescoffee

  • 1 on this! I need the same functionality too asap

Added an issue here https://github.com/glideapps/glide-data-grid/issues/1003

Druthi avatar Oct 29 '24 08:10 Druthi

Just poking around, and I haven't used this grid yet (though I have used other similar grids), ... but I would think that you would want to hide rows in the data itself rather than when rendering.

One way to do this, assuming you want to hide arbitrary rows, would be to keep the hidden row indexes or ids in a map and use that map to filter the dataset so that they are not presented to the grid in the first place in getData. Unhiding the rows or even a single row, would be removing it from the hidden rows map and then refreshing the grid. The grid renders so fast that it should appear instantaneous to the end user.

Maybe I'm wrong, just a suggestion.

domehead100 avatar Nov 28 '24 04:11 domehead100

Looking for this too.

luco avatar Feb 11 '25 02:02 luco

I would just create a hook like useColumnSort that maps allRows => visibleRows. Probably pass back rows and getCellContent appropriately. This can be handled outside of data grid editor already.

BrianHung avatar Jun 20 '25 21:06 BrianHung

I think what @BrianHung explained is the way to go here. What's missing is probably a good storybook case showcasing how best to do filtering. And maybe we can also provide a useRowFiltering hook in the sources packages to simplify a couple of aspects.

lukasmasuch avatar Jun 25 '25 10:06 lukasmasuch