Reputation: 23
I'm using angular-datatables with promise and everything work's fine. I have a lot of actions that can be done on each register (using angular $http resource) like change a status or something like that.
But, I need to reload datatable's data after every action even if i've edit just one line. And this process get's a little longer!
Is there any way to reload just the data that i've changed? For example, if I edit some line data I want just that line to be reloaded.
Forgive me if that's not a smart question, but I need to know if I can improve the performance of the actions over the table.
Here is my code!
DtOptions
vm.dtOptions = DTOptionsBuilder.fromFnPromise(function() {
vm.defer = $q.defer();
vm.mainService.getItems(idtask, flag, type).then(function(result)
vm.defer.resolve(result.data);
});
return vm.defer.promise;
})
.withOption('headerCallback', function(header) {
if (!vm.headerCompiled) {
vm.headerCompiled = true;
$compile(angular.element(header).contents())($scope);
}
})
.withPaginationType('full_numbers')
.withOption('createdRow', createdRow)
.withOption('deferRender', true)
.withDisplayLength(100)
.withOption('initComplete', function() { });
ReloadData function
function reloadData() {
var resetPaging = false;
vm.dtInstance.reloadData(function callback() {}, resetPaging);
}
After some execution over the table, I call the function reloadData().
Thanks for any help! And I'm sorry for my bad english.
Upvotes: 0
Views: 984
Reputation: 98
don't reload the page just append the last added data to the array in ng-repeat
with simple javascript push
consider below as array to which we want add last added element. write this in "success block" so if there is confirmation of successful post then this will be added to current stack. same can be done for delete and update.
var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.push("Kiwi");\
Upvotes: 0