数据表显示 aaData 值,但分页错误。
$("#tableData").DataTable({
"bProcessing": true,
"bServerSide": true,
"bsort":true,
"orderMulti":true,
"sAjaxSource":"datalist",
"sAjaxDataProp": function ( json ) {
var msgObj = JSON.parse(json);
console.log(msgObj)
return msgObj.aaData;
},
"aoColumns": [
{ "data": "scheduleId" },
{ "data": "startTime" },
{ "data": "endTime" },
{ "data": "selectFlag" }
]
});
这是 json 数据:
{"iTotalRecords":7,"iTotalDisplayRecords":7,"aaData":
[
{"scheduleId":1,"startTime":"02:00","endTime":"04:00","selectFlag":false},
{"scheduleId":2,"startTime":"02:00","endTime":"04:00","selectFlag":false},
{"scheduleId":3,"startTime":"02:00","endTime":"04:00","selectFlag":false},
{"scheduleId":4,"startTime":"02:00","endTime":"04:00","selectFlag":false},
{"scheduleId":5,"startTime":"02:00","endTime":"04:00","selectFlag":false},
{"scheduleId":6,"startTime":"02:00","endTime":"04:00","selectFlag":false},
{"scheduleId":7,"startTime":"03:00","endTime":"04:00","selectFlag":false}
]}
下面我附上了数据表的图像。
您能指出我犯的错误吗?
删除sAjaxDataProp
选项,它不是必需的。此外,您的 JSON 响应缺少 sEcho
参数,该参数是从客户端发送的 sEcho
的未更改副本。
参见Example JSON return了解更多详情。
参见this example用于代码和演示。请注意,该示例将无法正确排序/过滤/分页,因为没有可用的服务器端脚本。
我是一名优秀的程序员,十分优秀!