I’m using a custom CategoryFilter
for my categories AgGrid:
const columnDefs = [
{
field: 'categoryId',
headerName: t('category', { ns: 'common' }),
cellRendererSelector: (params: ICellRendererParams<IProduct>) => ({
component: CategoryColumn,
params: {
...params,
defaultLanguage
}
}),
filter: CategoryFilter,
floatingFilterComponentParams: {
suppressFilterButton: false,
},
}
]
When I filter by category, I can enter the value in the input field, but it’s still not showing up under the column’s name:
How do I display the selected category under the "Category" column title?
2
Answers
You can pass the
<CategoryColumn/>
reference to the parent component viaforwardRef
and access the parent model’s value via function params ofuseImperativeHandle
inside the<CategoryColumn/>
.Example
CategoryColumn
index.tsx
Have read of Ag-grid Floating Filter!
In column category component,
getModelAsString
method should return applied filters as mentioned. if no filter is applied then return null.