mData for JSON source
mData for JSON source
sdinesh21
Posts: 37Questions: 0Answers: 0
Hi,
I am using Datatables 1.9 and have the following JSON source from server
[code]
"aaData": [
[
11443013,
"Trading has officially closed",
"XBRN",
"18-Jul-2013 16:55:08:440"
],
[
11443012,
"Trading has officially closed",
"GITC",
203,
"18-Jul-2013 16:50:04:874"
]
[/code]
I need to access the JSON source to populate the datatable as follows. Since I do not have aaData objects as key/value pair, how do I access the using mData?
Please advise.
I am using Datatables 1.9 and have the following JSON source from server
[code]
"aaData": [
[
11443013,
"Trading has officially closed",
"XBRN",
"18-Jul-2013 16:55:08:440"
],
[
11443012,
"Trading has officially closed",
"GITC",
203,
"18-Jul-2013 16:50:04:874"
]
[/code]
I need to access the JSON source to populate the datatable as follows. Since I do not have aaData objects as key/value pair, how do I access the using mData?
Please advise.
This discussion has been closed.
Replies
Allan
[code]
"aaData": [
[
11443013,
"Test message 1",
"XBRN",
17,
4,
1,
"ABC (XBRN)",
"18-Jul-2013 16:55:08:440",
15,
"Test-A",
"Test sub"
],
[
11443012,
"Test message 2",
"GITC",
203,
4,
1,
"BCD (GITC)",
"18-Jul-2013 16:50:04:874",
15,
"Test-B",
"Test sub"
]
]
[/code]
And, this is how I try to fetch the JSON to populate the datatable.
[code]
"aoColumnDefs": [
{ "sTitle": "Time UTC", "aTargets": [ 7 ], "sName": "timeString", "bVisible": true, "bSortable": true},
{ "sTitle": "Type", "aTargets": [ 10 ],"sName": "description", "bVisible": true, "bSortable": true},
{ "sTitle": "Severity", "aTargets": [ 5 ], "sName": "severity", "bVisible": true, "bSortable": true},
{ "sTitle": "Subject", "aTargets": [ 6 ], "sName": "subject", "bVisible": true, "bSortable": true},
{ "sTitle": "User Name", "aTargets": [ 9 ], "sName": "userName", "bVisible": true, "bSortable": true},
{ "sTitle": "Description", "aTargets": [ 1 ], "sName": "message", "bVisible": false, "bSortable": true}
],
[/code]
Please let me know where am I going wrong. Thanks.
[code]
"aoColumnDefs": [
{ "sTitle": "Time UTC", "aTargets": [ 7 ], "bVisible": true, "mData" : "7", "bSortable": true},
{ "sTitle": "Type", "aTargets": [ 10 ], "bVisible": true, "mData" : "10", "bSortable": true},
{ "sTitle": "Severity", "aTargets": [ 5 ], "bVisible": true, "mData" : "5", "bSortable": true},
{ "sTitle": "Subject", "aTargets": [ 6 ], "bVisible": true, "mData" : "6", "bSortable": true},
{ "sTitle": "User Name", "aTargets": [ 9 ], "bVisible": true, "mData" : "9", "bSortable": true},
{ "sTitle": "Description", "aTargets": [ 1 ], "bVisible": false, "mData" : "1", "bSortable": true}
],
[/code]
[code]
"aoColumns": [
{ "sTitle": "Time UTC", "bVisible": true, "mData" : "7", "bSortable": true},
{ "sTitle": "Type", "bVisible": true, "mData" : "10", "bSortable": true},
{ "sTitle": "Severity", "bVisible": true, "mData" : "5", "bSortable": true},
{ "sTitle": "Subject", "bVisible": true, "mData" : "6", "bSortable": true},
{ "sTitle": "User Name", "bVisible": true, "mData" : "9", "bSortable": true},
{ "sTitle": "Description", "bVisible": false, "mData" : "1", "bSortable": true}
],
[/code]
Allan
I have posted another query in the following link. Can you please check that and help when you find time? Thanks.
http://datatables.net/forums/discussion/16491/column-data-wrapping-with-dynamic-number-of-columns#Item_2