DTInstances - Reloading of data is not working
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> Reload data
</button>
Is the dtInstance variable set in your table?
<table datatable
dt-options="showCase.dtOptions"
dt-columns="showCase.dtColumns"
dt-instance="showCase.dtInstance"></table>
Sure it was not! Thanks a lot, now it's working.
anything? I have the same problem.
It also works for me. thanks, I just need to follow this example http://codepen.io/l-lin/pen/Gpgxqo?editors=101
I had to use nested scope for dtInstance: see the answer here https://github.com/l-lin/angular-datatables/issues/347