HTML5 data-search cell attribute does not work
HTML5 data-search cell attribute does not work
Basically i'm trying to do something like in this example
https://datatables.net/examples/advanced_init/html5-data-attributes.html
My code is below
var dTable = $('#ajaxresults').DataTable({
"order": [[1, "desc" ]],
"sPaginationType": "full_numbers",
"ajax": "/users.json",
createdRow: function(row, data, index) {
if(data[6]=="Special") {
$(row).find('td').eq(0).attr("data-search", "Special");
}
}
});
However once the dataset is loaded on page and i'm trying to search for Special nothing returns but if i view it in dev tools i can clearly see the data-search attribute being set to the column, from what i've read i think i'm adding the data-search column attribute after the initialization and that's why the search would not work ? but i've searched the entire documentation and i don't see other ways to implement this does anyone have any ideas on this ?
This question has an accepted answers - jump to answer
Answers
found the solution on SO
columnDefs : [
{ targets: [0],
render: function ( data, type, full, meta ) {
if (type === 'filter') {
return full[6] == "Special" ? "Special" : data
} else {
return data
}
}
}
]