Theres something wrong with DataGrid search fields.

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
2 answers

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.





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.


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.