andness
andness10mo 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
Faton10mo 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
andness10mo 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
Faton10mo ago
Are the filters internal to Ag Grid? Sorry I misunderstood that. Let me check again and I'll get back to you
Faton
Faton10mo 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
andness10mo ago
Oh that's awesome @Faton ! Looking forward to it being merged!