HTML:
<table cellpadding="0" cellspacing="1" border="0" class="display" id="TableId">
<thead>
<tr>
<th>Name</th>
<th>Entry</th>
<th>Exit</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
dataTable函数:
$('#TableId').dataTable({
"bProcessing": true,
"bInfo": false,
"sAjaxSource": '/JSON/Path',
"bAutoWidth": false,
"bRetrieve":true
});
JSON:
{"aaData":[ ["Name 1","9516","4851"],
["Name 2","251304","127283"]
]}
我正在尝试在Entry和Exit之间添加不同的Column calc。
怎么做?
答案 0 :(得分:0)
您可以使用fnRowCallback
选项来获取该功能。 在标记中添加calc列
"fnRowCallback": function( nRow, aData, iDisplayIndex ) {
/* Append the grade to the default row class name */
var diff = aData[1]-aData[2];
$('td:eq(3)', nRow).html(diff);
return nRow;
},
"aoColumnDefs": [ {
"sClass": "center",
"aTargets": [ -1, -2 ]
} ]