Filter for table distinguish between accented words

I use the filter for datatables, but when I do the filter like this:
filter ="" + fd.field('Title').value + ""

    filterArray.push(filter);

………….
dt.filter = filterArray[0]
dt.refresh();

If title is Martín (with accent) it only searched for the accented word, my goal is that rows with title Martin (without accent) are returned.
This is how it works the search in a list or if you use a database, it is insensitive to accents.

Internally as you know the query is done with RenderListDataAsStream and a where clause.

Thx.

Hello @Miguel,

You can replace character when building the filter query:

fd.field('Title').value.normalize("NFD").replace(/[\u0300-\u036f]/g, "")

See this post form ore information:
https://stackoverflow.com/questions/990904/remove-accents-diacritics-in-a-string-in-javascript

But if I look for “Martin” instead of “Martín”, the filter is not going to give me the ones that has “Martín” with accent.
This is not the solution.

@Miguel,

You can add logic operator 'or' so teh search will be performed for both options:

        let filter = '<Or>';
        filter += '<Eq><FieldRef Name="Title"/><Value Type="Text">' + fd.field('Title').value.replace(/\u0131/g,'i')  + '</Value></Eq>';
        filter +=  '<Eq><FieldRef Name="Title"/><Value Type="Text">' + fd.field('Title').value  + '</Value></Eq>';
        filter += '</Or>';
1 Like