DTInstances
A DataTable directive instance is created each time a DataTable is rendered.
Helper/Wrapper | API | Description |
---|---|---|
DTInstance |
reloadData(callback, resetPaging) |
Reload the data of the DataTable. This API is only available for the Ajax Renderer and Promise Renderer!
angular.module('myModule', ['datatables']).controller('MyCtrl', MyCtrl);
function MyCtrl(DTOptionsBuilder, DTColumnBuilder) {
var vm = this;
vm.dtOptions = DTOptionsBuilder.fromSource('...');
vm.dtColumns = [...]
vm.dtInstance = {};
vm.reloadData = reloadData;
function reloadData () {
vm.dtInstance.reloadData();
});
}
|
DTInstance |
changeData(data)
Depending of the using renderer, you will need to provide:
|
Change the data of the DataTable. This API is only available for the Ajax Renderer and Promise Renderer!
angular.module('myModule', ['datatables']).controller('MyCtrl', MyCtrl);
function MyCtrl(DTOptionsBuilder, DTColumnBuilder) {
var vm = this;
vm.dtOptions = DTOptionsBuilder.fromSource('...');
vm.dtColumns = [...]
vm.dtInstance = {};
vm.changeData = changeData;
function changeData () {
// For Ajax renderers
vm.dtInstance.changeData('data.json');
// For Promise renderers
vm.dtInstance.changeData(function() {
return $resource('data.json').query().$promise;
});
});
}
|
DTInstance |
rerender()
|
This method will call the renderer to re-render the table again This is not the same as DataTable's draw(); API. It will completely remove the table, then it will re-render the table, resending the request to the server if necessarily.
angular.module('myModule', ['datatables']).controller('MyCtrl', MyCtrl);
function MyCtrl(DTOptionsBuilder, DTColumnBuilder) {
var vm = this;
vm.dtOptions = DTOptionsBuilder.fromSource('...');
vm.dtColumns = [...]
vm.dtInstance = {};
vm.rerender = rerender;
function rerender () {
vm.dtInstance.rerender();
});
}
|