Datatables render function, Individual column filtering
Datatables render function, Individual column filtering
Hello,
Does anyone know why the Individual column filtering breaks, when using below? It works when using clientside, but the filtering breaks when using this on server side (Server side is the same, just with row[8] instead of data.Name.
Its a function to display a small icon beside the name, and it works. It just breaks the Individual column filtering for some reason when using it on serverside (client side works fine).
I figure its something in the SSP class that needs to be modified, but not exactly sure how to - hope someone can help.
columns: [
{ data: null, render: function ( data, type, row ) {
if (row.Navn.includes("Jem")) {
return '<img src="assets/img/icons/custom/jf.png"></img> ' + data.Name;
}
} },
],
Answers
You should probably use
data: 'Name'
for that column. That way the SSP class will know what data point it should operate on for the filtering -null
means it can't know what to filter on.Another issue with the above is that if the
if
condition doesn't pass, then the function returns undefined. You should addreturn ''
for such cases.Note that since this is a client-side rendering function, the SSP search can't take account of that function and the logic in it. You'd need to build a VIEW in your SQL which you can then query if that condition is an important part of the filtering logic.
Allan