I am using angular ui-grid - AngularJS. I have a dropdown on a column, allowing me to filter on the cellValues. But I have noticed that the searchTerm sometimes gets escape characters on certain values.
The version of the grid I am using is this:
The cellValue is how I see it in the UI. But the searchTerm sometimes gets escape characters on certain values. Below are some examples of this, where the cellValue is on top and the searchTerm is below:
"My Text- My Text – My Text"
"My Text\- My Text – My Text"
"My Text- My Text (2015-2020)"
"My Text\- My Text \(2015\-2020\)"
"My Text (2015-2020)"
"My Text \(2015\-2020\)"
Here is the code which creates the column definition in the grid:
$scope.gridOptions = {
columnDefs: [
{
name: "Type",
field: "typeNavn",
enableColumnMenu: false,
cellTemplate: myCellToolTipTemplate,
width: 110,
filterHeaderTemplate: myDownFilter,
filter: {
term: null,
options: [],
condition: function (searchTerm, cellValue, row, column) {
if (searchTerm === cellValue) {
return true;
} else {
return false;
}
}
}
}
Any ideas on why searchTerm sometimes gets escape characters on certain values?
Something elegant to do about it?
Of course I can use a Regex, but maybe there is a more elegant solution?
var searchTermWithoutEscapeCharacters = searchTerm.replace(/\\/g, "");