I've a few predefined filter options on my page to filter my datatable. When clicking one, it gets added to the filter of the specific column. But I've a big problem with whitespaces... for example I've those options:
"old & good", "cheap & nice", "expensive"
All clicked options are stored in an array. For filtering I do
var term = array.join('|'); //--> term = "old & good|cheap & nice|expensive"
dataTable.fnFilter(term, column, true, true);
It works fine if there are no strings with whitespaces and "&" or only one. a solo "cheap & nice" is working, but "cheap & nice|expensive" doesn't... also "expensive|what|ever" works when there are no whitespaces.
How can I get the filter work?
--------edit----------
some further explanation:
My code imports data from (user-defined) csv and generates for the first column some buttons, one for every unique entry in this column. The user can click on the buttons to filter the table, only the clicked entrys should be displayed. The button gets the entry as value, like in this example.
<input type="button" value="cheap & nice" onclick="myFilterFunction(this)"/>
To know wich buttons have been clicked, their value gets stored in a normal array. My callback function for the click looks into this array, joins the names to one regexp and gives this string to the fnFilter(), like posted above.
This works fine as long as there is no entry with whitespaces in it. But i can't remove the whitespaces, because then the filter can't find the entry wich really has whitespaces in it.