0

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);
6
  • As long you are rendering the "dataTables way" i.e datatable="" then only visible rows will be rendered. Commented Sep 21, 2016 at 10:53
  • but i using the angular way Commented Sep 21, 2016 at 11:20
  • Yes, figured that out :) And that is your problem. None of dataTables optimisation features works when the whole drawing/rendering job is beeing "outsourced" to angular. Commented Sep 21, 2016 at 11:23
  • Ok, so what can i do? Commented Sep 21, 2016 at 11:30
  • 2
    Nothing. Angular is an extreme bottleneck regarding performance, and you cannot optimise ng-repeat in conjunction with dataTables. You must render with dataTables if you want to boost performance. Commented Sep 21, 2016 at 11:36

1 Answer 1

0

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.