Dynamic Headers (json array)
Dynamic Headers (json array)
Hello,
I have a JSON array like below and I would like to use Dynamic Column Headers in the DataTable.. As you see there is a propertyAdaptor array in json array .. "PropertyAdaptor.name" should be a Column header and "PropertyAdaptor.value" should be this clumn value.. (If there is an other way to get headers I am open new ideas :)
JSON Array
[code]
[
{"systemId":"86210","endOfUse":"","startOfUse":"","dateModified":"26/03/2012 04:59","identity":"P600540","name":"xxxx","propertyAdaptor":[{"name":"Description","value":"test test test test test"},{"name":"Group","value":"B"},{"name":"Point","value":"1411"}]},
{"systemId":"86211","endOfUse":"","startOfUse":"","dateModified":"26/03/2012 04:59","identity":"P600550","name":"yyyy","propertyAdaptor":[{"name":"Description","value":"test test test test test"},{"name":"Group","value":"C"},{"name":"Point","value":"979"}]},
{"systemId":"86212","endOfUse":"","startOfUse":"","dateModified":"26/03/2012 04:59","identity":"P600560","name":"zzzz","propertyAdaptor":[{"name":"Description","value":"test test test test test"},{"name":"Group","value":"A3"},{"name":"Point","value":"10733"}]}
]
[/code]
DataTable
Note: sTitle gets "propertyAdaptor.0.name" as a string so It doesn't work.. And I don't know propertyAdopters array size() so It is the other problem for me.
[code]
$('#editEntityTable').dataTable( {
"bServerSide": false,
"bProcessing": true,
"bDeferRender": true,
"sAjaxSource": "../servlets/EntityListWithDraftsServlet?entityTypeId="+id,
"sServerMethod": "GET",
"bRetrieve": true,
"sAjaxDataProp": "",
"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
$(nRow).addClass('gradeA');
},
"fnInitComplete": function(oSettings, json) {
resize();
hideLoading();
},
"aoColumns": [
{ "mDataProp": "systemId"},
{ "mDataProp": "identity"},
{ "mDataProp": "name"},
{ "mDataProp": "dateModified"},
{ "mDataProp": "startOfUse"},
{ "mDataProp": "endOfUse"},
{ "mDataProp": "propertyAdaptor.0.value","sTitle": "propertyAdaptor.0.name"}
],
"bRetrieve": true,
"bAutoWidth": false
});
[/code]
Thanks,
Merih
I have a JSON array like below and I would like to use Dynamic Column Headers in the DataTable.. As you see there is a propertyAdaptor array in json array .. "PropertyAdaptor.name" should be a Column header and "PropertyAdaptor.value" should be this clumn value.. (If there is an other way to get headers I am open new ideas :)
JSON Array
[code]
[
{"systemId":"86210","endOfUse":"","startOfUse":"","dateModified":"26/03/2012 04:59","identity":"P600540","name":"xxxx","propertyAdaptor":[{"name":"Description","value":"test test test test test"},{"name":"Group","value":"B"},{"name":"Point","value":"1411"}]},
{"systemId":"86211","endOfUse":"","startOfUse":"","dateModified":"26/03/2012 04:59","identity":"P600550","name":"yyyy","propertyAdaptor":[{"name":"Description","value":"test test test test test"},{"name":"Group","value":"C"},{"name":"Point","value":"979"}]},
{"systemId":"86212","endOfUse":"","startOfUse":"","dateModified":"26/03/2012 04:59","identity":"P600560","name":"zzzz","propertyAdaptor":[{"name":"Description","value":"test test test test test"},{"name":"Group","value":"A3"},{"name":"Point","value":"10733"}]}
]
[/code]
DataTable
Note: sTitle gets "propertyAdaptor.0.name" as a string so It doesn't work.. And I don't know propertyAdopters array size() so It is the other problem for me.
[code]
$('#editEntityTable').dataTable( {
"bServerSide": false,
"bProcessing": true,
"bDeferRender": true,
"sAjaxSource": "../servlets/EntityListWithDraftsServlet?entityTypeId="+id,
"sServerMethod": "GET",
"bRetrieve": true,
"sAjaxDataProp": "",
"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
$(nRow).addClass('gradeA');
},
"fnInitComplete": function(oSettings, json) {
resize();
hideLoading();
},
"aoColumns": [
{ "mDataProp": "systemId"},
{ "mDataProp": "identity"},
{ "mDataProp": "name"},
{ "mDataProp": "dateModified"},
{ "mDataProp": "startOfUse"},
{ "mDataProp": "endOfUse"},
{ "mDataProp": "propertyAdaptor.0.value","sTitle": "propertyAdaptor.0.name"}
],
"bRetrieve": true,
"bAutoWidth": false
});
[/code]
Thanks,
Merih
This discussion has been closed.
Replies