我们正在尝试刷新数据表。
我们已经尝试过这种方式,但它显示错误,因为mData未定义。
setTimeout(function () {
oTable.fnClearTable();
oTable.fnDraw();
oTable.fnAddData();
}, 3000);
var oTable = $('#example').DataTable({
"bProcessing": true,
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"sAjaxSource": "../controllers/JQGridBOTMonitoringDashboard.php",
"aoColumns": [{
"mData": "bot"
}, {
"mData": "ip_address"
}, {
"mData": "status",
"fnRender": function (obj) {
var status = obj.aData.status;
if (status == 'online') {
obj.oSettings.aoColumns[obj.iDataColumn].sClass = "greenBackground"
} else {
obj.oSettings.aoColumns[obj.iDataColumn].sClass = "redBackground"
}
return status;
}
}, {
"mData": "os"
}, {
"mData": "os_version"
}, {
"mData": "last_execution_time"
},
{
"sTitle": "ACTIONS",
"sClass": "center",
"sDefaultContent": '<a class="bot_show"><img src="images/button_view.png"/></a>',
"bSortable": false,
"bSearchable": false,
"fnRender": function (obj) {
var id = obj.aData.id;
obj.oSettings.aoColumns[obj.iDataColumn].sClass = id;
}
}
]
});