单击下一步按钮时,服务器连续处理数据 table
Server process data table continously when next button is clicked
我使用数据table 在我的后端处理大数据。在 DTOptionsBuilder 中,我使用 withFnServerData 方法从数据库中获取一系列数据。它从头到尾解析了 table 中的所有内容。但是下面的分页号总是一个。好像不行,我只能用左上角的数字过滤器,但不是我想要的。
控制器
$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.
问题出在过滤数据部分,因为我的数据被过滤了,没有显示所有数据。只需更改根据可用总数据过滤的记录即可解决问题。
records = {
'draw': draw,
'recordsTotal': response.total_data,
'recordsFiltered':response.total_data, // Change total_data
'data': response.result
};
我使用数据table 在我的后端处理大数据。在 DTOptionsBuilder 中,我使用 withFnServerData 方法从数据库中获取一系列数据。它从头到尾解析了 table 中的所有内容。但是下面的分页号总是一个。好像不行,我只能用左上角的数字过滤器,但不是我想要的。
控制器
$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.
问题出在过滤数据部分,因为我的数据被过滤了,没有显示所有数据。只需更改根据可用总数据过滤的记录即可解决问题。
records = {
'draw': draw,
'recordsTotal': response.total_data,
'recordsFiltered':response.total_data, // Change total_data
'data': response.result
};