I have a html multi select field
in one column of jquery datatable(http://datatables.net), I want to search(from its default search box) only selected options in select fields and not unselected ones . Its currently searching all the text inside select field.
What I would need is to remove unselected options from search.
Can anyone suggest how to do it ?
Thanks.
Edit: I have created custom sType
and defined $.fn.dataTableExt.ofnSearch
for it. As specified at- (http://datatables.net/development/filtering) in "Type based column filtering". Code is Given below:-
$.fn.dataTableExt.aTypes.push(
function ( sData )
{
var ishtml=sData.match(/<select(?:.)*?>.*<\/select>/gm);
if (ishtml)
{
return 'comments';
}
return null;
}
);
$.fn.dataTableExt.ofnSearch['comments'] = function ( sData ) {
return sData.replace(/<select(?:.)*?>.*<\/select>/gm, "");
}
And added stype
to columndef in .dataTable( { } )
"aoColumnDefs": [{ "sType": "comments", "aTargets": [ 8 ] }],
It will remove complete select element text (selected and unselected both)from search. Then I will use jquery to add selected options to hidden div outside of select to let them available in search. But this is still considering select field text in search.
Any ideas? Please let me know if any one can help.