Open levireciprocity opened 7 months ago
What exactly are you trying to do? Could you give an example in code?
Just asking because you can get the type from your column definition with the mandatory field
property on the GridFilterItem
.
It could look something like this:
const handleFilterModelChange = (model: GridFilterModel) => {
const modelItemsWithType: Array<GridFilterItem & { type: GridColDef['type'] }> =
model.items.map((item) => ({
...item,
type: apiRef.current.getColumn(item.field).type,
}));
console.log('itemsWithType', modelItemsWithType);
};
Here is a working example of that handler: FilterModelItems with type
Yeah this is the solution I have, rather than mapping through the items to get the type I'd like to just have the type on the GridFilterItem with operatorValue, value, columnField and id
OK, imo this should be sufficient and not blur the API even more, but I'll put this on the board nonetheless for the team to look at.
Summary
Add the type field to the GridFilterItem interface on the GridFilterModel, this field would help for server-side datagrid filtering https://v5.mui.com/x/react-data-grid/column-definition/#column-types
Examples
instead of specifying the column field on the backend i could grab the column type from the api to determine filter operators and logic
Motivation
make server-side datagrid filtering more generic
Search keywords: type GridFilterItem GridFilterModel server-side filtering