-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DataGrid] Add "does not equal" and "does not contain" filter operators #14489
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Made that change a1e27b8 This is likely an issue for some translated operator labels too, but not sure of the best way to account for those right now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Agreed, I think we should be mindful of this when finalizing the new filter panel design. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,21 @@ export const getGridStringOperators = ( | |
}, | ||
InputComponent: GridFilterInputValue, | ||
}, | ||
{ | ||
value: 'doesNotContain', | ||
getApplyFilterFn: (filterItem: GridFilterItem) => { | ||
if (!filterItem.value) { | ||
return null; | ||
} | ||
const filterItemValue = disableTrim ? filterItem.value : filterItem.value.trim(); | ||
|
||
const filterRegex = new RegExp(escapeRegExp(filterItemValue), 'i'); | ||
return (value): boolean => { | ||
return value != null ? !filterRegex.test(String(value)) : true; | ||
}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be great to extract a function that will handle both There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense - will create a follow up PR for this improvement 👍 |
||
}, | ||
InputComponent: GridFilterInputValue, | ||
}, | ||
{ | ||
value: 'equals', | ||
getApplyFilterFn: (filterItem: GridFilterItem) => { | ||
|
@@ -53,6 +68,21 @@ export const getGridStringOperators = ( | |
}, | ||
InputComponent: GridFilterInputValue, | ||
}, | ||
{ | ||
value: 'doesNotEqual', | ||
getApplyFilterFn: (filterItem: GridFilterItem) => { | ||
if (!filterItem.value) { | ||
return null; | ||
} | ||
const filterItemValue = disableTrim ? filterItem.value : filterItem.value.trim(); | ||
|
||
const collator = new Intl.Collator(undefined, { sensitivity: 'base', usage: 'search' }); | ||
return (value): boolean => { | ||
return value != null ? collator.compare(filterItemValue, value.toString()) !== 0 : true; | ||
}; | ||
}, | ||
InputComponent: GridFilterInputValue, | ||
}, | ||
{ | ||
value: 'startsWith', | ||
getApplyFilterFn: (filterItem: GridFilterItem) => { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Off-topic, but should we add string labels in place of numeric symbols?
=
=>Equals
!=
=>Not equals
and so on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think so.
It would also match what we have in header filters:
I will create a follow up PR 👍