Basic Json object parsing

Basic Json object parsing

ririckririck Posts: 11Questions: 0Answers: 0
edited June 2011 in General
I'd like to get a datatable without reparsing it.

The typical object I get from my server is an array of json objects like:
[{"col1":"colvalue1","col2":"colvalue2"},{"col1":"colvalue1","col2":"colvalue2"},{"col1":"colvalue1","col2":"colvalue2"}]

I am building my table completely dynamically in the js code like:
$('#demo').html('');
$('#example').dataTable(data)({
"bJQueryUI": true,
"aoColumns": [
{"mDataProp": "col1"}, {"mDataProp": "col2"}
]
});

I can see the data arriving from the server correctly but then I get an error:

oColumn is undefined
[Break On This Error] oSettings.aaSorting[i][1] = oColumn.asSorting[0];

What am I doing wrong?

Replies

  • ririckririck Posts: 11Questions: 0Answers: 0
    Ok seems I was missing Table Header in the table basic structure.
    Now it works with:
    $('#demo').html('col1col2')
    and
    $('#example').dataTable({
    "bJQueryUI": true,
    "aaData": data,
    "aoColumns": [
    {"mDataProp": "col1"}, {"mDataProp": "col2"}

    ]
    });
This discussion has been closed.