我正在尝试构建一个可能有100多个条目的表。在初始化插件时,我将bServerSide
属性设置为true
以使用服务器端处理进行分页。在我的表的JSON数据中,我设置iTotalRecords
等于过滤前的记录总数,iTotalDisplayRecords
等于过滤记录的数量。就我而言,这两个值彼此相等。
对于少于100条记录,分页按预期工作。但是,如果有超过100个条目,则会创建几个空页。
例如,这是一个表,每页有108个条目和20个条目。第6页应该是表格的最后一页,但链接一直持续到第11页,其中任何页面都没有数据。
有谁知道我可能会缺少什么?看起来非常奇怪的是,分页的效果与99条记录的预期相同,但不是101条记录。
我的初始化代码:
$table.dataTable({
"sDom": "<'row'<'col-sm-4'f><'col-sm-8'>r>t<'row'<'col-sm-4'i><'col-sm-8'p>>",
"bDrawing": true,
"bServerSide": true,
"bScrollCollapse": true,
"bProcessing": true,
"bInfo": false,
"bAutoWidth": false,
"pageLength": 20,
"sPaginationType": "full_numbers",
"bPaginate": true,
"bSortClasses": false,
"sPageButton": "button",
"aoColumns": aoColumns,
"sAjaxSource": _typeSettings.getAllTagsUrl,
"sAjaxDataProp": "bleTags.Tags",
});
我的数据样本,如1个条目所示:
{
"bleTags":{
"Tags":[
{
"index":"0",
"discoveryTime":{
"TimeStamp":"1507834225",
"MilliSec":"733"
},
"iBeacon":{
"UUID":"E2C56DB5-DFFB-48D2-B060-D0F5A71096E0",
"major":"21845",
"minor":"9029"
},
"packets":"2006",
"RSSI":"-93",
"battery":"0",
"name":"",
"lastPacket":{
"TimeStamp":"1507926755",
"MilliSec":"693"
},
"manufacturer":"0x004C",
"online":"false"
}
]
},
"iTotalRecords":1,
"iTotalDisplayRecords":1
}
示例REST调用:
http://localhost/restapi/ble/GetBLETags?sEcho=2&iColumns=10&sColumns=&iDisplayStart=40&iDisplayLength=10&mDataProp_0=0&mDataProp_1=function&mDataProp_2=function&mDataProp_3=function&mDataProp_4=function&mDataProp_5=function&mDataProp_6=function&mDataProp_7=function&mDataProp_8=function&mDataProp_9=9&sSearch=&bRegex=false&sSearch_0=&bRegex_0=false&bSearchable_0=true&sSearch_1=&bRegex_1=false&bSearchable_1=true&sSearch_2=&bRegex_2=false&bSearchable_2=true&sSearch_3=&bRegex_3=false&bSearchable_3=true&sSearch_4=&bRegex_4=false&bSearchable_4=true&sSearch_5=&bRegex_5=false&bSearchable_5=true&sSearch_6=&bRegex_6=false&bSearchable_6=true&sSearch_7=&bRegex_7=false&bSearchable_7=true&sSearch_8=&bRegex_8=false&bSearchable_8=true&sSearch_9=&bRegex_9=false&bSearchable_9=true&iSortCol_0=0&sSortDir_0=asc&iSortingCols=1&bSortable_0=false&bSortable_1=false&bSortable_2=false&bSortable_3=false&bSortable_4=false&bSortable_5=false&bSortable_6=true&bSortable_7=false&bSortable_8=false&bSortable_9=false