1

I follow this library https://l-lin.github.io/angular-datatables/archives/#!/serverSideProcessing to create a server-side processing datatable. It works very well but may I know how to get current page?

 var vm = this;
        vm.dtOptions = DTOptionsBuilder.newOptions()
            .withOption('ajax', {
                // Either you specify the AjaxDataProp here
                url: 'api/bank_recon/fetch_trx',
                type: 'POST',

            })
            .withDataProp('data')
            .withOption('processing', true)
            .withOption('serverSide', true)
            .withPaginationType('full')
taydukakni
  • 11
  • 3

1 Answers1

1

You can use drawCallback function to get page information , you can assign that value to scope by using javascript angular element selector methods.

 vm.dtOptions = DTOptionsBuilder.newOptions().
                    .withOption('drawCallback', function(settings) {
                          if(settings.aoData.length > 0) {
                            var api = this.api();
                            var pgNo = api.page.info();
                            var currPg = pgNo.page;
                            var totalPg = pgNo.pages;

                            var scope = angular.element($("#outer")).scope();
                            scope.$apply(function(){
                               scope.currentpage = currPg;
                            })
                          }
                     })
                });
Ajarudin Gunga
  • 433
  • 3
  • 21