问题
I am using angular datatables with fnPromise and my data is about 10,000 rows also i use scrollY and i want to render only the visible rows for performence My code:
vm.dtOptions = DTOptionsBuilder.fromFnPromise(function() {
var defer = $q.defer();
var dataPageParams = {
columnFilters: [],
endIdx: -1,
startIdx: -1,
filterParams: parentVM.filterParams,
sortDescending: false,
instanceID: parseData.instanceId
};
if (parentVM.filterId !== '') {
dataPageParams.filterID = parentVM.filterId;
}
DataService.GetDataPage(dataPageParams, dataPageParams.instanceID).then(function (pageDataResult) {
var data = pageDataResult.data.Data;
defer.resolve(data);
});
return defer.promise;
}).withLanguage(tableText)
.withScroller()
.withOption('scrollY', 410)
.withOption('scrollCollapse', true)
.withOption('deferRender', true)
.withPaginationType('full_numbers')
.withOption('rowCallback', rowCallback)
.withOption('lengthMenu', [[-1, 10, 50, 100, 500], [$translate.instant("ALL"), 10, 50, 100, 500]])
.withOption('createdRow', createdRow);
回答1:
As i am seeing, you are using the scroller plugin, this plugin in particularly, it will render the datatatable in a different way, it will render the rows in blocks larger than the value of the scrollY, when you scroll the content, and you are close to view the end of the first block, it will render a 2nd block, so, if you want to use the deferRender you will need to remove this plugin.
来源:https://stackoverflow.com/questions/39613485/angular-datatables-the-deferrender-not-working