Column filters
Implement column filtering to help users refine and sort data.
Example
Key Points
TMeta Generic for Better IntelliSense:
You can pass an additional type to
ColumnDef<InventoryItem, YOUR_TYPE>[]
to enhance IntelliSense support for the_meta
field.Using
_meta
for Custom Data:The
_meta
field allows you to pass any custom data while keeping it fully typed.Checking If a Column is Filterable:
You can determine if a column is filterable by accessing its options:
column.options.filterable
Choosing Which Filters to Render:
datagrid
does not enforce a specific way to determine which filters to render.
For example, you can use the_meta
field like this:_meta: { filterType: 'range' }
This is just an example—you can use any structure that suits your needs.
Passing Options For Select:
I found it easy to pass options in this way, again it’s up to you.
filterOptions: [ { label: 'Computers', value: 'Computers' }, { label: 'Clothing', value: 'clothing' } ]