我是jquery datatable的新手,所以我需要帮助解决这个问题:
每当点击'Next'页面时,api就会被调用,响应json也会显示在datatable中。 现在,单击“上一页”页面按钮,api即被调用,并且能够从后端获得响应,但数据表未使用新的JSON数据重置。
请指导我解决此问题。
以下是我的代码:
使用Javascript:
$(document).ready(function() {
var empColumns = [];
empColumns.push({
"sTitle" : "Emp.Id",
"sClass" : "left",
"sWidth" : "10%"
}, {
"sTitle" : "Name",
"sClass" : "left",
"sWidth" : "10%"
}, {
"sTitle" : "Designation",
"sClass" : "left",
"sWidth" : "10%"
});
$("#example").dataTable( {
"bProcessing": false,
"bServerSide": true,
"sort": "position",
"bStateSave": false,
"iDisplayLength": 10,
"iDisplayStart": 0,
"sAjaxSource": "api/getEmpDetails",
"aoColumns": empColumns
});
});
JSON数据:
{
"draw": 1,
"recordsTotal": 57,
"recordsFiltered": 57,
"data": [
[
"1",
"Marshall",
"Regional Director"
],
[
"2",
"Hurst",
"Javascript Developer"
],
[
"3",
"Rios",
"Personnel Lead"
],
[
"4",
"Snider",
"Customer Support"
],
[
"5",
"Wilder",
"Sales Assistant"
],
[
"6",
"Camacho",
"Support Engineer"
],
[
"7",
"Green",
"Chief Operating Officer (COO)"
],
[
"8",
"Winters",
"Accountant"
],
[
"9",
"Joyce",
"Developer"
],
[
"10",
"Cortez",
"Team Leader"
]
]
}
提前致谢....