Checking data type in renderer
Checking data type in renderer
Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:
I am trying to check render type (display, sort, ...) and not getting the right value and can't figure out what I am doing wrong.
When I debug and check the renderer's parameters, 'data' is an IP address, 'row' is all the column values and 'type' is always "type" instead of "display" or "sort" or ...
It is a simple check and should work out of the box:
"columns": [
{
"data": "CLIENTIP",
"render": function (data, type, row) {
if (type === 'display') { // This returns "type", "if" statement never executes
var cellContent = '';
if (null != data && '' != data) {
cellContent = "<span class='PageLink'>" + data + "</span>";
}
return cellContent;
}
return data;
}
}, {
...
}
This question has an accepted answers - jump to answer
Answers
This example here may help. It's using
columns.render
in a similar fashion to you. Could you look at that, please, and see if it helps. If it's still not working for you, please can you update my example, or link to your page, so that we can see the problem.Colin
Thank you @colin
I wanted to open a modal showing details when IP address was clicked. I solved the issue using below and bypassing the "type" check.
Thank you for your feedback. Love datatables even though it has caused losing a few strands of hair every now and then
Looks like a good solution - thanks for posting back
Allan