I'm using DataTables with server side data to display several tables with details (expanding sub tables). There are two types of sub tables one with three columns one with 7 columns.
I would like to set the value of aoColumns
after I have retrieved data from the server and before the row is displayed but Im having a hard time doing it. Here is what I have so far.
self.createDataTable = function(identifier, source, rowCallback, initCallback) {
var columnsA = [
{ "mDataProp": "index", "sClass": "index", "bSortable": false },
{ "mDataProp": "text", "sClass": "top-dd", "bSortable": false },
{ "mDataProp": "stats", "sClass": "top-dd stats", "bSortable": false }
];
var columnsB = [
{ "mDataProp": "index", "sClass": "index", "bSortable": false },
{ "mDataProp": "check-box", "sClass": "check-box" },
{ "mDataProp": "foundDate", "sClass": "date" },
{ "mDataProp": "pageLink", "sClass": "link" },
{ "mDataProp": "linkText", "sClass": "text" },
{ "mDataProp": "ipAddress", "sClass": "ip" },
{ "mDataProp": "otherLinks", "sClass": "more dd-second-" + thisTR.id }
];
$(identifier).dataTable({
"bPaginate": false,
"bLengthChange": false,
"bFilter": false,
"bSort": true,
"bInfo": false,
"bAutoWidth": false,
"oLanguage": { "sEmptyTable": 'No patterns found' },
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": source,
"fnServerParams": function(aoData) {
aoData.push({ "name": "uniqueid", "value": self.uniqueid },
{ "name": "basedomain", "value": basedomain },
{ "name": "return_this", "value": $(this).data('returnid') });
},
"aoColumns": columnsA,
"fnRowCallback": function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
return rowCallback(nRow, aData);
},
"fnInitComplete": function(oSettings, iStart, iEnd, iMax, iTotal, sPre) {
initCallback();
}
});
Basically I would like to catch data from the server, look at a flag passed from the server, set aoColumns and then continue as normal. Any ideas? Im looking through the callback functions http://datatables.net/usage/callbacks but Im having a hard time setting the columns once Im in a callback.
I'm also reading the following but Im not getting the desired results.