Skip to content

useGridFiltering

Hook for programmatic filter control.

Must be used within a DataGrid component tree with filtering enabled.

useGridFiltering(selector: string): FilteringMethods
NameTypeDescription
selectorstringOptional CSS selector to target a specific grid element via
DOM query instead of using React context. Use when the component contains
multiple grids, e.g. 'tbw-grid.primary' or '#my-grid'.
import { useGridFiltering } from '@toolbox-web/grid-react/features/filtering';
function QuickFilters() {
const { setFilter, clearAllFilters, getFilteredRowCount, isFieldFiltered } = useGridFiltering();
return (
<div>
<input
placeholder="Filter by name..."
onChange={(e) => setFilter('name', e.target.value ? { operator: 'contains', value: e.target.value } : null)}
/>
<span>{getFilteredRowCount()} rows</span>
<button onClick={clearAllFilters}>Clear All</button>
</div>
);
}
AI assistants: For complete API documentation, implementation guides, and code examples for this library, see https://raw.githubusercontent.com/OysteinAmundsen/toolbox/main/llms-full.txt