only first strings are shown when using sAjaxSource and custom JSON
only first strings are shown when using sAjaxSource and custom JSON

Hello.
I'm using custom JSON as Ajax source and the problem is that only first string from each row is printed into the table.
Screenshot of the final rendered table: https://www.dropbox.com/s/d4zhklk1p14fphf/Screenshot%202014-01-10%2013.39.33.png
Sorry for the screenshot, my web is in localnet without access from the outside.
Can someone tell my what is wrong? Thank you in advance.
My JSON:
[code]
{
"Sortlist" : null,
"Comments" : null,
"Options" : null,
"Nameservers" : [
"192.168.4.254",
"62.168.96.4",
"8.8.8.8"
],
"Domain" : null,
"Searchlist" : [
"in.example.com"
]
}
[/code]
And table code and initialization sequence:
[code]
Nameservers
$('#table-dnsdata').dataTable( {
"sAjaxSource" : "dns_data.json",
"sAjaxDataProp" : "Nameservers",
"oLanguage" : {
"sUrl" : "/assets/js/dataTables-en.UTF-8.txt"
}
[/code]
I'm using custom JSON as Ajax source and the problem is that only first string from each row is printed into the table.
Screenshot of the final rendered table: https://www.dropbox.com/s/d4zhklk1p14fphf/Screenshot%202014-01-10%2013.39.33.png
Sorry for the screenshot, my web is in localnet without access from the outside.
Can someone tell my what is wrong? Thank you in advance.
My JSON:
[code]
{
"Sortlist" : null,
"Comments" : null,
"Options" : null,
"Nameservers" : [
"192.168.4.254",
"62.168.96.4",
"8.8.8.8"
],
"Domain" : null,
"Searchlist" : [
"in.example.com"
]
}
[/code]
And table code and initialization sequence:
[code]
Nameservers
$('#table-dnsdata').dataTable( {
"sAjaxSource" : "dns_data.json",
"sAjaxDataProp" : "Nameservers",
"oLanguage" : {
"sUrl" : "/assets/js/dataTables-en.UTF-8.txt"
}
[/code]
This discussion has been closed.
Replies
If not, then I think you might need to modify the at a client-side. I _think_ DataTables 1.10 might actually be able to cope with this, but it would need a configuration something like `data: null` for the column. I remember testing it ages ago to be able to cope with that kind of thing...
Allan
It worked as you mentioned (wrap each value in an array). Anyways, i would love to try 1.10 version way. What do you exactly mean by "data:null for the column"?
Thank you
$('#example').dataTable( {
// ...
columns: [
{ data: null }
]
} );
[/code]
Something like that I think.
Allan
[code]
{
"aaData": [
[
"Trident",
"Internet Explorer 4.0",
"Win 95+",
"4",
"X"
],
[
"Trident",
"Internet Explorer 5.0",
"Win 95+",
"5",
"C"
],
[
"Trident",
"Internet Explorer 5.5",
"Win 95+",
"5.5",
"A"
],
[
"Trident",
"Internet Explorer 6",
"Win 98+",
"6",
"A"
]
]
}
[/code]