今天遇到这样的问题,就是利用jQuery dataTables表格插件,将我后台返回来的JSON数据填充,但是不能分页,而是显示全部的数据,很奇怪,这是运行的截图和jQuery dataTables参数的设置,大牛们帮忙看看,小弟也是刚接触jQuery dataTables。
[code="java"]
function loadCustomerInfo(){
var datatable;
if(datatable == undefined || datatable == "undefined" || datatable == null){
$("#exportTable").show();
datatable=$("#exportTable").dataTable({
"sPaginationType": "full_numbers",
"bFilter":false,
"bSort":false,
"iDisplayLength": 5,
"bRetrieve":true,
"bPaginate":true,
"bLengthChange": false,
"bStateSave" :false,
"bServerSide": true,
"aoColumns": [ {"mDataProp":"customerID"},
{"mDataProp":"customerName"},
{"mDataProp":"customerTel"},
{"mDataProp":"salesDate"},
{"mDataProp":"operate",
"mRender": function(data, type, full) {
return '订单详情';}
}],
"oLanguage":{
"sLengthMenu": "每页显示 MENU 条记录",
"sZeroRecords": "没有检索到数据",
"sInfo": "显示 START-_END_ 条数据;共有 TOTAL 条记录",
"sInfoEmtpy": "没有数据",
"sProcessing": "正在加载数据...",
"oPaginate":
{
"sFirst": "首页",
"sPrevious": "上一页",
"sNext": "下一页",
"sLast": "尾页"
}
},
"sAjaxSource" : "../CustomerServlet?rand="+Math.random(),
"fnServerData" : function(sSource, aoData, fnCallback){
$.getJSON(
sSource,
{contractID:$("#contractID").val(),
customerName:encodeURI(encodeURI($("#customerName").val())),
customerTel:$("#customerTel").val(),
aoData:JSON.stringify(aoData)} ,
function callback(data){
fnCallback(data);
});
}
});
}
else{
datatable.fnDestroy();
}
datatable.fnDraw();
}
[/code]
[img]
[/img]