Dynamically update column header based on filtered data #439
Replies: 2 comments 3 replies
-
so It seems like I can use the const filteredData = tableInstanceRef.current.getFilteredRowModel();
const totalItems = filteredData.flatRows.reduce((acc, curr) => {
return acc + parseInt(curr.original.number_of_items);
}, 0);
however it seems to only run once initially and not after i've filtered for some data. |
Beta Was this translation helpful? Give feedback.
0 replies
-
@KevinVandy do you have any idea? I basically want the Global Filter to function the way it does but just re-calculate some data whenever the filter (global filter) is applied and the user searches for something in the TextField input and then display that data in the column header. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, I'm using your Material-React-Table library in my project and would like to know if it's possible to dynamically update a column header based on the current filtering applied to the table data.
Here's an example to illustrate my use case:
Let's say I have a column header called "Items" and there are 10 rows in the table, each containing the data "1" in each row for that column. If I apply a filter to the table so that it displays only 3 rows with 1 item each, I would like the header for that column to be updated to "Items (3)" to reflect the current number of displayed items.
Is there any built-in functionality to achieve this or could you suggest a possible approach to implement this feature?
Thank you for your help and for creating this great library!
Beta Was this translation helpful? Give feedback.
All reactions