Theres something wrong with DataGrid search fields.

0
Hi all, I input the following signs into the search field and searched it. However, it was not the result that I expected. _ % A sign of two above is the sign that should escape by the general development, but works like a query when I input in search field. About this issue, is there the person knowing the solution?   Best Regards, Toshiya Anada
asked
2 answers
2

Indeed you need to escape those characters and is indeed not so user friendly. You could try to create your own search box as a workaround.

Regards,

Ronald

 

answered
2

Hi Toshiya,

So if you would be able to manually escape it from the input as you commented to your question, another workaround could be using the html snippet to add an javascript escape function to the search button click and the on enter event of your search field like something as below. Name the input field for example "searchDescription" and the grid "searchGridExample". Below code should get you a some way in the right direction. I guess you have to check as well if it's not escaped already to prevent false results when clicking twice or pressing enter in the search field twice. You could use some regex functionality for that.

Snippet:

https://github.com/mendix/HTMLSnippet

Simple example:

function escapefunction(){
$('.mx-name-searchDescription').find(':input')[0].value = $('.mx-name-searchDescription').find(':input')[0].value.replace("%", "\\%");
};

$('.mx-name-searchGridExample .mx-grid-searchbar .mx-grid-search-controls .mx-grid-search-button')[0].addEventListener("click", escapefunction, false);

Still is not a very nice way because the user still sees the escape chars in your input searchfield but if acceptable would be another alternative.

Regards,

answered