Skip to content

Commit a75e65a

Browse files
feat(filter): Add rawTerm option to columnDef filter options
Adds the rawTerm option to the columnDef filter options, when enabled it causes the rowSearcher to skip trimming and escaping the search term, providing the raw value to the specified filter condition. This is intended for use with custom search condition functions where pre-escaping all regular expression characters or trimming whitespace is not desired. Relates to #2475
1 parent 7748148 commit a75e65a

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/js/core/factories/GridColumn.js

+2
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,8 @@ angular.module('ui.grid')
740740
* - ariaLabel: String that will be set to the `<input>.ariaLabel` attribute. This is what is read as a label to screen reader users.
741741
* - noTerm: set this to true if you have defined a custom function in condition, and
742742
* your custom function doesn't require a term (so it can run even when the term is null)
743+
* - rawTerm: set this to true if you have defined a custom function in condition, and
744+
* your custom function requires access to the raw unmodified search term that was entered
743745
* - flags: only flag currently available is `caseSensitive`, set to false if you don't want
744746
* case sensitive matching
745747
* - type: defaults to {@link ui.grid.service:uiGridConstants#properties_filter uiGridConstants.filter.INPUT},

src/js/core/services/rowSearcher.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,11 @@ module.service('rowSearcher', ['gridUtil', 'uiGridConstants', function (gridUtil
125125

126126
if ( !gridUtil.isNullOrUndefined(filter.term) ){
127127
// it is possible to have noTerm.
128-
newFilter.term = rowSearcher.stripTerm(filter);
128+
if ( filter.rawTerm ){
129+
newFilter.term = filter.term;
130+
} else {
131+
newFilter.term = rowSearcher.stripTerm(filter);
132+
}
129133
}
130134
newFilter.noTerm = filter.noTerm;
131135

0 commit comments

Comments
 (0)