angular-datatables icon indicating copy to clipboard operation
angular-datatables copied to clipboard

DTInstances - Reloading of data is not working

Open Chalkin opened this issue 11 years ago • 5 comments

When i follow the example here: https://l-lin.github.io/angular-datatables/#/dataReloadWithPromise

I always get an "TypeError: vm.dtInstance.reloadData is not a function" error

I have tried with the exact same code as stated in the example and i have tried to implement it into mine, which is also resulting in the same error.

        var vm = this;
        vm.dtOptions = DTOptionsBuilder.fromFnPromise( function()
        {
            return $resource($scope.sourceUrl).query().$promise;
        })
            .withOption('bInfo', false)
            .withOption('paging', false)
            .withOption('filter', false)
            .withOption('rowCallback', rowCallback);

        // Create the table columns
        vm.dtColumns = [
            DTColumnBuilder.newColumn('customer').withTitle('Kunde / Anzeigedrucke'),
            DTColumnBuilder.newColumn('today').withTitle('Heute'),
            DTColumnBuilder.newColumn('week').withTitle('7 Tage'),
            DTColumnBuilder.newColumn('month').withTitle('30 Tage')
        ];

        vm.newPromise = newPromise;
        vm.reloadData = reloadData;
        vm.dtInstance = {};

        function reloadData()
        {
            var resetPaging = false;
            vm.dtInstance.reloadData(callback, resetPaging);
        }

        function callback(json)
        {
            console.log(json);
        }
<button ng-click="controller.reloadData()" type="button" class="btn btn-info">
                    <i class="fa fa-refresh"></i>&nbsp;Reload data
                </button>

Chalkin avatar Jun 18 '15 12:06 Chalkin

Is the dtInstance variable set in your table?

<table datatable
    dt-options="showCase.dtOptions"
    dt-columns="showCase.dtColumns"
    dt-instance="showCase.dtInstance"></table>

l-lin avatar Jun 18 '15 12:06 l-lin

Sure it was not! Thanks a lot, now it's working.

Chalkin avatar Jun 18 '15 13:06 Chalkin

anything? I have the same problem.

rabelorp avatar Apr 01 '16 12:04 rabelorp

It also works for me. thanks, I just need to follow this example http://codepen.io/l-lin/pen/Gpgxqo?editors=101

nemcuon avatar May 30 '16 12:05 nemcuon

I had to use nested scope for dtInstance: see the answer here https://github.com/l-lin/angular-datatables/issues/347

trainoasis avatar Dec 04 '17 11:12 trainoasis