I have a datatable which is defined as
$('#group').dataTable( {
"sDom": '<"H"fi>t<"F">',
"aaSorting": [ [2,'asc'], [1,'asc'] ],
"aoColumnDefs": [
{"aTargets": [ 0 ], "sType": null, "bSortable": false, "bSearchable": false },
{"aTargets": [ 1, 2 ], "sType": "html", "asSorting": [ "asc", "desc" ] },
{"aTargets": [ 3 ], "sType": "gcse-grade", "asSorting": [ "desc", "asc" ] },
{"aTargets": [ "_all" ], "sType": "grade", "asSorting": [ "desc", "asc" ] }
],
"bAutoWidth": false,
"bFilter": true,
"bInfo": true,
"bLengthChange": false,
"bPaginate": false,
"bScrollAutoCss": true,
"bScrollCollapse": true,
"bSort": true,
"oLanguage": { "sSearch": "_INPUT_" }
}
);
As you can see I have used custom sTypes called grade
and gcse_grade
. I have custom sorting working fine using oSort. However, when I create the table these columns sometimes have HTML tags within them.
How can I filter these so that it firstly strips the HTML tags from within. i.e. so the filter only sees the text, not the tags (as I don't want the filter to pick up any , or tags).
I have a fiddle here
If this is just for sorting purposes, try this:
If you need it for filtering (and sorting, et. al.), just use the
fnRowCallback
function instead to manipulate the actual content before the table is drawn:To strip html tags on filter search, you can use something like this: