only first strings are shown when using sAjaxSource and custom JSON

only first strings are shown when using sAjaxSource and custom JSON

holdengerholdenger Posts: 3Questions: 0Answers: 0
edited January 2014 in DataTables 1.9
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]

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Are you able to modify your JSON return - if so, just wrap each value in Nameservers in an array.

    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
  • holdengerholdenger Posts: 3Questions: 0Answers: 0
    Hello allan, thank you for your fast answer,

    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
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    [code]
    $('#example').dataTable( {
    // ...
    columns: [
    { data: null }
    ]
    } );
    [/code]

    Something like that I think.

    Allan
  • holdengerholdenger Posts: 3Questions: 0Answers: 0
    Oh, right, thank you, will try
  • bigsipperbigsipper Posts: 31Questions: 2Answers: 0
    Here's an example JSON file that works for me... note the key 'aaData' at the top. I read (somewhere) it was necesarry:

    [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]
This discussion has been closed.