Json with different number of items. How generate a table ?
Json with different number of items. How generate a table ?
Hello!
I am new to DataTables, BTW great project!
I have problem with generate a table, when number of items in json data is different.
eg.
[code]
'[{"temp": 18.6, "light": 616, "nodeid": "node2", "press": 1003.5, "humi": 92.5, "date": "26/08/2012 15:11", "batvol": 423}]'
[/code]
and
[code]
'[{"date": "26/08/2012 15:14", "nodeid": "node5", "temp": 23.9}]'
[/code]
Now i realize it by code:
[code]
testdata = {{ last }};
console.log(testdata);
$('#ttable').dataTable({
"aaData":testdata,
"bFilter": false,
"bSearchable":false,
"bInfo":false,
"bPaginate": false,
"aoColumns":[
{"mDataProp":"date"},
{"mDataProp":"nodeid"},
{"mDataProp":"temp"},
{"mDataProp":"light"},
{"mDataProp":"press"},
{"mDataProp":"humi"},
{"mDataProp":"batvol"}]
});
[/code]
This work byt got awful error like:
[code]
'DataTables warning (table id = 'ttable'): Requested unknown paramater 'light' from data source for row 1'
[/code]
There is any fix or different way to display dynamic items in json data in one table?
You are my last hope...
I am new to DataTables, BTW great project!
I have problem with generate a table, when number of items in json data is different.
eg.
[code]
'[{"temp": 18.6, "light": 616, "nodeid": "node2", "press": 1003.5, "humi": 92.5, "date": "26/08/2012 15:11", "batvol": 423}]'
[/code]
and
[code]
'[{"date": "26/08/2012 15:14", "nodeid": "node5", "temp": 23.9}]'
[/code]
Now i realize it by code:
[code]
testdata = {{ last }};
console.log(testdata);
$('#ttable').dataTable({
"aaData":testdata,
"bFilter": false,
"bSearchable":false,
"bInfo":false,
"bPaginate": false,
"aoColumns":[
{"mDataProp":"date"},
{"mDataProp":"nodeid"},
{"mDataProp":"temp"},
{"mDataProp":"light"},
{"mDataProp":"press"},
{"mDataProp":"humi"},
{"mDataProp":"batvol"}]
});
[/code]
This work byt got awful error like:
[code]
'DataTables warning (table id = 'ttable'): Requested unknown paramater 'light' from data source for row 1'
[/code]
There is any fix or different way to display dynamic items in json data in one table?
You are my last hope...
This discussion has been closed.
Replies
Allan