Custom Global filtering

Custom Global filtering

priyam_maheshwaripriyam_maheshwari Posts: 1Questions: 0Answers: 0
edited February 2014 in General
I have a column in my datatable which has text with spaces in it. I want to be able to filter my data table providing text with or without spaces. As in I should be able to search for "the search text" giving search term as "thesearchtext" as well as "the search text". Individual column filtering is working fine for me by using the following code.
[code]
/* Removes spaces from a given text*/
var textStrip = function (data) {
return data.replace(/\s/g, '');
}

/* functions used by JQuery datatables to sort columns specified as type "names" */
jQuery.fn.dataTableExt.oSort['names-asc'] = function (a, b) {
var ordA = textStrip(a);
var ordB = textStrip(b);
return (ordA < ordB) ? -1 : ((ordA > ordB) ? 1 : 0);
}
jQuery.fn.dataTableExt.oSort['names-desc'] = function (a, b) {
var ordA = textStrip(a);
var ordB = textStrip(b);
return (ordA < ordB) ? 1 : ((ordA > ordB) ? -1 : 0);
}

jQuery.fn.dataTableExt.ofnSearch['names'] = function ( sData ) {
var searchString=textStrip(sData);
return sData + ","+ searchString;
}
[/code]

But I am having issues with global search. ofnSearch is not used by global search it seems. I am not sure how to customise global search to be able to have above kind of search functionality
This discussion has been closed.