Filter Panel
The toolbar's Filter rule builder (column, operator, value, AND / OR, Apply) is also a standalone
component, <GridFilterPanel>. Put it in a sidebar, a drawer or above the grid. It edits the grid's own
filter state through apiRef, so the toolbar's Filter button and badge show the same rules.
Loading demo…
import { useRef } from 'react';
import { DataTable, GridFilterPanel, type DataTableApi } from '@ackplus/mui-tanstack-data-grid';
function UsersPage() {
const apiRef = useRef<DataTableApi<User> | null>(null);
return (
<>
<GridFilterPanel apiRef={apiRef} />
<DataTable apiRef={apiRef} columns={columns} data={rows} enableColumnFilter />
</>
);
}
How it behaves
- Needs
enableColumnFilteron the grid. Without it the panel renders nothing. - Pending, then Apply. Rules are drafts until Apply, the same as in the toolbar. Clear all
removes the applied filters. Both call
onDone, so a drawer can close itself. - Client or server. It changes the grid's filter state, so
filterMode="server"works as usual: youronFetchDatagets the applied filters. See Filtering for operators and value inputs. - Anywhere in the tree, before or after the grid, and fine if the grid mounts later.
- Themeable. The root is the
filterPanelslot:components.MuiTanstackDataGrid.styleOverrides.filterPanel.
Props
| Prop | Type | Description |
|---|---|---|
apiRef | RefObject<DataTableApi | null> | The apiRef you pass to <DataTable>. Required. |
heading | string | The title. Default: localeText.filterTitle. |
onDone | () => void | Called after Apply and Clear all. |
addFilterIcon, removeFilterIcon | ComponentType | Replace the icons. |
className, sx | Style the root. |
To build a filter UI of your own, use useGridApi(apiRef)
with the filtering API.