Skip to main content

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 enableColumnFilter on 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: your onFetchData gets 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 filterPanel slot: components.MuiTanstackDataGrid.styleOverrides.filterPanel.

Props​

PropTypeDescription
apiRefRefObject<DataTableApi | null>The apiRef you pass to <DataTable>. Required.
headingstringThe title. Default: localeText.filterTitle.
onDone() => voidCalled after Apply and Clear all.
addFilterIcon, removeFilterIconComponentTypeReplace the icons.
className, sxStyle the root.

To build a filter UI of your own, use useGridApi(apiRef) with the filtering API.