andness
andness11mo ago

Get the number of filtered rows when using AgGrid

I'm trying to get the number of filtered rows when using the AgGrid. I've found that this should be available as getAgGrid("myTable").api.getDisplayedRowCount(), but when using this in a templated text it does not update. The problem seems to be that the text component depends on myTable.selectedRows and myTable.result (I also print the total count and the selected count in the same text. But it has no dependency that makes it re-render when the filtering changes. Is there anything I can do to make it update on filter changes?
5 Replies
Faton
Faton11mo ago
Hi, you can make a frontend script that will read the displayedRowCount and configure it to trigger anytime some dependency changes (for example your filters). You can then use the result of the frontend script in your templated text.
andness
andnessOP11mo ago
Hm, it's the trigger I can't figure out. It seems agGrid has a filterChanged event which could achieve this, but I'm not sure how to hook up the filterChange event with the frontend script?
Faton
Faton11mo ago
Are the filters internal to Ag Grid? Sorry I misunderstood that. Let me check again and I'll get back to you
Faton
Faton11mo ago
I've made a PR to expose both the state of the filters and the displayedRowCount in the output of the component: https://github.com/windmill-labs/windmill/pull/3101/files
andness
andnessOP11mo ago
Oh that's awesome @Faton ! Looking forward to it being merged!