How can I remove filter options from React Data Grids filters? For example when I do FilterEditior: SelectFilter it shows "Contains", "Does not contain", "Equal" etc but I only want the filtering options to be "Contains" and "Equal". I can only find a way to add filtering options with renderColumContextMenu but none to remove.
Asked
Active
Viewed 583 times
1 Answers
0
Their renderColumnContextMenu
property allows customization of the Context Menu (the menu at the top of each column with a "3 line" icon).
It sounds like you want renderColumnFilterContextMenu
, which allows customization of the Filter Context Menu (the menu with "Not in list" etc). They provide an example here: https://reactdatagrid.io/docs/api-reference#props-renderColumnFilterContextMenu.
For example to remove their "Not in list" menu item, modify the renderColumnFilterContextMenu
function from that example as follows:
const renderColumnFilterContextMenu = useCallback((menuProps, {
cellProps }) => {
// Limit this change to the specific column,
// by referring to its id or name from your columns array.
if (cellProps.id === 'country') {
menuProps.items = menuProps.items.filter((item) => item.itemId !== 'operator-notinlist');
}
}, []);
Note: I know you specifically asked about the "Does not contain" menu item, but in their 4.21.0 community/enterprise versions I see it as "Not in list".

Eric Del Sesto
- 1
- 1
-
I was looking to remove filters that were in the list already. So things like "contains", "equals", "empty" as they're not useful in some of my use cases. – ohvictah Sep 13 '22 at 00:04