AJAX source understanding format

AJAX source understanding format

uskerineuskerine Posts: 33Questions: 15Answers: 0

So far I have managed to get datatables working with AJAX by defining them as:

var oFooTable = $('#fooTable').dataTable({
...
"sAjaxSource": "getFooList?type=SUPERFOO&status=FULLFOO"
});

This requires the data to be delivered in the following format:

{ "aaData": [ ["data1","data2","data3" ]] }

If I understood it correctly, this is like sort kind of array notation.
However, at the server side, JSON library (GSON - Java) cosntruct JSON messages like this:

{
"field1":"data1",
"field2":"data2",
"field3list": [
{ "d1":"foo1","d2":"foo2"},
{ "d1":"foo10","d2":"foo20"}
]
}

Is it possible for datatables to deal with a "standard" JSON object like the previous one and populate automatically the table?
If so, what parameters should be used instead or in companion to sAjaxSource?

Thanks!

Replies

  • uskerineuskerine Posts: 33Questions: 15Answers: 0

    CORRECTION: the right analog JSON construct for the example would be:

    { "aaData": [ {"field1": "data1", "field2": "data2", "field3": "data3"}, ... ] }

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin

    Sure - see the manual.

    Allan

  • uskerineuskerine Posts: 33Questions: 15Answers: 0

    Brilliant it is working with JSON objects now.
    I also moved definitions to 1.10 API.

    Thanks!

This discussion has been closed.