How to escape apostrophe in grid filter

I am loading a dhtmlxgrid with data from an IBM AS400 with the dhtmlxconnector and an .ashx file. The data being pulled is a list of vendors, some of which include an apostrophe in their names. I am using the “#connector_text_filter” to filter the Vendors column and when a user attempts to search for a vendor whose name includes an apostrophe, using an apostrophe in the filter field, it throws an error. The error is not produced by the data, it is thrown when the user enters an apostrophe in the filter field. What is the best way to escape the apostrophe? Should I remove it in the “connector_ItemPrerender” subroutine or is there something I can tell the users to do when filtering? Thanks!

As far as I can see the client side code is not affected by apostrophe, so the problem must occurs on server side. In such case the best approach will be to sanitize data on server side ( in the ashx file )

Also, it possible to alter code of filter, so it will remove dangerous chars before sending data to the server-side.