我正在使用带有服务器端数据的 DataTables 来显示几个带有详细信息的表(扩展子表)。有两种类型的子表,一种是三列,一种是七列。
我想在aoColumns
从服务器检索数据之后和显示行之前设置值,但我很难做到这一点。这是我到目前为止所拥有的。
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();
}
});
基本上我想从服务器捕获数据,查看从服务器传递的标志,设置 aoColumns 然后正常继续。有任何想法吗?我正在查看回调函数http://datatables.net/usage/callbacks但我很难在回调中设置列。
我也在阅读以下内容,但我没有得到想要的结果。