How to filter results with special characters using jQuery DataTables plugin?
How to filter results with special characters using jQuery DataTables plugin?
I am using the jQuery DataTables plugin in my application, and many of my table rows and filters have special characters, specifically ampersands (&) in them. When I try to filter on these columns, all records disappear and it displays "no matching records found".
I have tried encoding (i.e. htmlspecialchars) and decoding (i.e. htmlspecialchars_decode) the strings before they are printed onto the page, but neither seems to be working.
Example: http://jsfiddle.net/gkdcZ/3/
I have my question posted on StackOverflow too:
http://stackoverflow.com/questions/8962316/how-to-filter-results-with-special-characters-using-jquery-datatables-plugin
Any ideas why this might be happening, and how I can fix it?
I have tried encoding (i.e. htmlspecialchars) and decoding (i.e. htmlspecialchars_decode) the strings before they are printed onto the page, but neither seems to be working.
Example: http://jsfiddle.net/gkdcZ/3/
I have my question posted on StackOverflow too:
http://stackoverflow.com/questions/8962316/how-to-filter-results-with-special-characters-using-jquery-datatables-plugin
Any ideas why this might be happening, and how I can fix it?
This discussion has been closed.
Replies
I also have the same issue. However, the only difference is that I have a Ñ and ñ characters on my data.
I displayed my data using server-side processing. The characters from the database is exactly Ñ or ñ since it is utf8 encoded and inserted as is. I added the PHP function [code] htmlentities() [/code] to avoid null data on the dataTbles:
[code]
if ( $aColumns[$i] == "hospital_name" )
{
/* Special output formatting for 'hospital_name' column */
$row[] = ($aRow[ $aColumns[$i] ]=="0") ? '-' : htmlentities($aRow[ $aColumns[$i] ]);
}
else if ( $aColumns[$i] != ' ' )
{
/* General output */
$row[] = $aRow[ $aColumns[$i] ];
}
[/code]
Now when searching on the filter text box: pressing alt+num1+num6+num5(for Ñ); filtering does not work and no result is found.
Hope someone could give us inputs here.
Thank you very much in advanced.
I've got similar issues with chars like 'ö' and 'ï' ... which are quite common in dutch/german/...