Handle null value without aoColumnDefs nor aoColumns: is it possible?

Handle null value without aoColumnDefs nor aoColumns: is it possible?

danieletsdanielets Posts: 11Questions: 0Answers: 0
edited March 2013 in General
I would like datatable generate the table based on an indexed json source something like this:
[code]
{
"0": "Gecko",
"1": "Mozilla 1.0",
"2": null,
"3": "Win 95+ / OSX.1+",
"4": "A",
"5": ""
}
[/code]
Since index 2 is a null i obviously get the well known error message "Requested unknown parameter...".
One option would be to replace null values with empty strings in the server side process, but i'd rather find another option. I don't like to mess with data like that, since distinction between real empty strings and null values exists i want to keep it.

i tried with this:
[code]
"aoColumnDefs" : [
{ "mData": null
, "sDefaultContent": ""
, "aTargets": [ "_all" ]
}
]
[/code]

but then all data vanish and i left with all empty strings.
Please tell there is another way to ignore null values.
Thanks.

Replies

  • allanallan Posts: 63,522Questions: 1Answers: 10,473 Site admin
    Don't set mData to null there - that means that sDefaultContent will always be used!

    Allan
  • danieletsdanielets Posts: 11Questions: 0Answers: 0
    It worked. Thank you.
    I was pretty much sure i did already try that but obviously i was remembering wrong.
This discussion has been closed.