gpt4 book ai didi

javascript - Angularjs Datatable 服务器端分页

转载 作者:数据小太阳 更新时间:2023-10-29 05:51:51 26 4
gpt4 key购买 nike

我正在尝试在此链接中制作 Angularjs 数据表服务器端分页 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');

我在 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]

添加后的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]

问题是分页不起作用,数据表在一页中显示所有数据,当我点击分页按钮时没有任何 Action 。

最佳答案

返回的 JSON 格式应该是:

{
data: [{Object},{Object},{Object},{Object}…]
draw: "1"
recordsFiltered: 91
recordsTotal: 91
}

您可以从这里获得关于 Datatables server-side paging, sorting and filtering in angularjs 的完整教程

关于javascript - Angularjs Datatable 服务器端分页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33475840/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com