Repository navigation
How to reset any applied filters on click of hide filters #1433
Replies: 1 comment
|
Yes. In MRT v3 the show/hide button only changes import {
MRT_ToggleFiltersButton,
useMaterialReactTable,
} from 'material-react-table';
const table = useMaterialReactTable({
columns,
data,
renderToolbarInternalActions: ({ table }) => (
<MRT_ToggleFiltersButton
table={table}
onClick={() => {
const nextVisible = !table.getState().showColumnFilters;
table.setColumnFilters([]);
table.setShowColumnFilters(nextVisible);
}}
/>
),
});That clears column filters on every click. To clear only when hiding the filter row, change the clearing line to: if (!nextVisible) table.setColumnFilters([]);For your alternative behavior—prevent toggling until all column filters are cleared—use the default click handler and pass renderToolbarInternalActions: ({ table }) => (
<MRT_ToggleFiltersButton
table={table}
disabled={table.getState().columnFilters.length > 0}
/>
),Choose one behavior. These examples clear/check column filters. The global search is separate; also call I checked the v3 button source: it forwards IconButton props after its default |
Uh oh!
There was an error while loading. Please reload this page.
Hello Team,
I am looking for a way to reset any applied filters when we click on show/hide filters icon. Is there a way we can achieve this.
Additionally is it possible to disable show/hide filter Icon until all applied filters are cleared similar to how the search Icon works ?
All reactions