angular-datatables the deferRender not working

别来无恙 提交于 2019-12-25 06:49:48

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!