Basic Json object parsing
Basic Json object parsing
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?
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?
This discussion has been closed.
Replies
Now it works with:
$('#demo').html('col1col2')
and
$('#example').dataTable({
"bJQueryUI": true,
"aaData": data,
"aoColumns": [
{"mDataProp": "col1"}, {"mDataProp": "col2"}
]
});