How do I replace undefined column value to blank string?
How do I replace undefined column value to blank string?
BrettA
Posts: 12Questions: 4Answers: 0
Hi, I am running Datatables on a SharePoint 2013 doc library and if a field is empty for a specific item, Datatables displays the value as "undefined".
Can someone please tell me how to replace "undefined" with a "tba" string or blank value or whatever?
I have looked everywhere but cannot find the answer.
Thanks.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Hi @BrettA ,
The way to go is with
columns.render
, see the examples near the bottom of the page. You can just test for "undefined", and return any other string, such as "tba".Cheers,
Colin
Hi Colin, thanks for replying but I cannot see what you are referring to.
Can you paste the code here, so I can try it please?
Thanks.
in cols or columnDefs do something like
columnDefs:[{targets:[3], render:function(data){if(data == null) {return "tbd"} else {return data}}
Thank you bindrid,
I changed your code a little, used "undefined" and it works now:
with 2 == signs, the if statement checks for both a null and a undefinded in javascript