Possible bug: Hiding rows in a data grid

I’ve noticed some unexpected behaviour with Data Grids when hiding rows.

  1. Hidden rows count towards the number of rows in a grid. (So a 10 row page might show fewer than 10 rows if some are hidden, even if I have 1000 rows of actual data)
  2. Paging through data unhides rows.
  3. We might need a paging event so we can hide rows at that point.

Anyway, here’s a fairly minimal example [1] showing behaviour, with explanation of why it’s unexpected.

I expect that for my use case, my data should be filtered before the rows are created.

[1] https://42EMQDMAKTHQS34J.anvil.app/6MCNJJT2TMIN56KFOUJNOZGL

Hi @brendon_yenson,

Thanks for providing an example app. Could I get a clone link to take a closer look?

Thanks,
Ryan

Hi @ryan,
Sorry - I thought I’d made a clone-able link. I’m new at this!
https://anvil.works/build#clone:42EMQDMAKTHQS34J=CM3D7AXHLGHTDWQJVQTMDXFJ
Cheers,
Brendon

Hi @ryan,
I’m just bumping this issue to make sure it’s not lost to history.
Thanks!
Brendon

Hi @brendon_yenson,

Apologies, thanks for being patient.

In your example, the repeating panel creates the components (panel.items = items). Then each new row component is hidden based on their number. The main issue is that you’re only doing this on the initialisation of the parent form not on the initialisation of the data grid rows.

You’re right about the need for an event handler but instead of the event handler being on the parent form, it is on the row component. refresh_data_bindings is triggered every time the data grid is initialised or the page number is changed. In the fixed example below, I’ve added that event handler to the row template and then hidden the object depending on its number in the event handler. I’ve also reduced the number of data grid rows to 5 because hidden rows don’t count towards the grids total.

Clone link for the fixed example:
https://anvil.works/build#clone:4GLNQAGCX43RKTJU=ICWQOXRSNNUFXE35JOXFDFFE

I hope that helps.

Ryan