Why does angular ui-grid (AngularJS) put an escape character on certain characters in a dropdown filter?

4 views
Skip to first unread message

cowi...@gmail.com

unread,
Jul 11, 2019, 3:09:51 AM7/11/19
to UI-Grid Support
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 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, "");

Reply all
Reply to author
Forward
0 new messages