-
Hi, I need a button to clear all column filters at once, I can manage the |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
There is a table instance resetColumnFilters api Combine that knowledge with the custom internal toolbar buttons example |
Beta Was this translation helpful? Give feedback.
-
For anyone in the future looking for this. function CustomTable({ data, columns, isLoading, state, ...rest }) {
const [columnFilters, setColumnFilters] = useState([]);
const [showColumnFilters, setShowColumnFilters] = useState(false);
return (
<MaterialReactTable
columns={columns}
data={data}
state={{ isLoading, columnFilters, showColumnFilters, ...state }}
onColumnFiltersChange={setColumnFilters}
onShowColumnFiltersChange={() => setShowColumnFilters(v => !v)}
//customize built-in buttons in the top-right of top toolbar
renderToolbarInternalActions={({ table }) => (
<Box>
{!!columnFilters.length && (
<Tooltip title="Reset filters" arrow>
<IconButton
onClick={() => {
setShowColumnFilters(false);
setColumnFilters([]);
}}
>
<FilterAltOffOutlinedIcon />
</IconButton>
</Tooltip>
)}
{/* Built-in buttons*/}
<MrtToggleFiltersButton table={table} />
<MrtShowHideColumnsButton table={table} />
<MrtToggleDensePaddingButton table={table} />
<MrtFullScreenToggleButton table={table} />
</Box>
)}
{...rest}
/>
);
} |
Beta Was this translation helpful? Give feedback.
You can use
resetColumnFilters
by callingtable.resetColumnFilters()