gpt4 book ai didi

javascript - 单击下一步按钮时服务器连续处理数据表

转载 作者:行者123 更新时间:2023-11-30 21:08:28 26 4
gpt4 key购买 nike

我使用数据表在后端处理大数据。在 DTOptionsBuilder 中,我使用 withFnServerData 方法从数据库中获取一系列数据。它从头到尾解析了表中的所有内容。但是下面的分页号总是一个。似乎不起作用,我只能使用左上角的数字过滤器,但这不是我想要的。

Controller

$scope.dtColumns = [
DTColumnBuilder.newColumn('d', 'column').withOption('defaultContent', ""),
DTColumnBuilder.newColumn('m', 'mukim').withOption('defaultContent', ""), ....
];

$scope.pageData = {
total: 0
};

var get = function(sSource, aoData, fnCallback, oSettings){
var draw = aoData[0].value;
var order = aoData[2].value;
var start = aoData[3].value;
var length = aoData[4].value;

var params = {
start:start,
limit:length
};

ValuationService.SearchValuation(params, function(result, response){
if(result == true){
var records = {
'draw': 0,
'recordsTotal': 0,
'recordsFiltered': 0,
'data': []
};
if(response.result){
records = {
'draw': draw,
'recordsTotal': response.total_data,
'recordsFiltered':response.result.length,
'data': response.result
};
}
$scope.pageData.total = response.total_data;

fnCallback(records);
}
});
}

$scope.dtOptions = DTOptionsBuilder.newOptions()
.withFnServerData(get) // method name server call
.withDataProp('data')// parameter name of list use in getLeads Fuction
.withOption('processing', true) // required
.withOption('serverSide', true)// required
.withOption('paging', true)// required
.withPaginationType('full_numbers')
.withDisplayLength(10)
.withOption('rowCallback', rowCallback)
.withDOM('lrtip');

function rowCallback (nRow, aData, iDisplayIndex, iDisplayIndexFull) {
$compile(nRow)($scope);
}

HTML

table.row-border.hover(datatable="", dt-instance="dtInstance",dt-columns="dtColumns", dt-options="dtOptions" style="overflow:auto;")

我想要什么

The table below will show the number of pagination. I can click the next and previous. When I click next, it will call the API again to retrieve and parse another start to limit into table.

当前问题

Table pagination shows '1' only, next button disabled. 

I can solve the issue by select the number at top left corner, but it shown in one page which I don't want.

enter image description here

最佳答案

问题出在过滤数据部分,因为我的数据被过滤了,没有显示所有数据。只需更改根据可用总数据过滤的记录即可解决此问题。

records = {
'draw': draw,
'recordsTotal': response.total_data,
'recordsFiltered':response.total_data, // Change total_data
'data': response.result
};

关于javascript - 单击下一步按钮时服务器连续处理数据表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46378241/

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