Ali*_*abi 5 javascript jquery datatables angularjs angular-datatables
我正在尝试在此链接中进行Angularjs Datatable服务器端分页https://l-lin.github.io/angular-datatables/#/serverSideProcessing
所以我使用这段代码
$scope.dtOptions = DTOptionsBuilder.newOptions()
.withOption('ajax', {
dataSrc: function(json) {
conole.log(json)
json['recordsTotal'] =json.length
json['recordsFiltered'] = json.length
json['draw']=1
conole.log(json)
return json;
},
url: 'api/footestrecords',
type: 'GET'
})
.withOption('processing', true)
.withOption('serverSide', true)
.withPaginationType('full_numbers');
Run Code Online (Sandbox Code Playgroud)
我在dataSrc参数中手动添加了recordsTotal,recordsFiltered和row
这是添加recordsTotal,recordsFiltered和row之前和之后的json数据
添加之前的json数据
[Object, Object, Object, Object, Object, Object, Object, Object,
Object,Object, Object, Object, Object, Object, Object, Object, Object,
Object, Object, Object, Object, Object, Object, Object, Object, Object,
Object, Object]
Run Code Online (Sandbox Code Playgroud)
添加后的json数据
[Object, Object, Object, Object, Object, Object, Object, Object,
Object, Object, Object, Object, Object, Object, Object, Object, Object,
Object, Object, Object, Object, Object, Object, Object, Object,
Object,Object, Object, recordsTotal: 28, recordsFiltered: 28, draw: 1]
Run Code Online (Sandbox Code Playgroud)
probelm是分页不起作用,数据表显示一页中的所有数据,而当我点击分页按钮时没有动作.
Sou*_*dal 10
返回的JSON格式应该是:
{
data: [{Object},{Object},{Object},{Object}…]
draw: "1"
recordsFiltered: 91
recordsTotal: 91
}
Run Code Online (Sandbox Code Playgroud)
您可以从这里获得有关数据表服务器端分页,排序和过滤angularjs的完整教程