Load/Reload the table data from an Ajax source
This module also handles data reloading / loading from an Ajax source:
-
If you need to load data, you just have to override the
dtOptions.sAjaxSource
property.
-
If you need to reload the data, you just have to call the function
dtOptions.reloadData();
.
However, you need to either have the fnReloadAjax
plugin or have a recent version of DataTable (v1.10+) in order to use this feature.
angular.module('datatablesSampleApp', ['datatables'])
.controller('dataReloadWithAjaxCtrl', function($scope, DTOptionsBuilder, DTColumnBuilder) {
$scope.reloadData = function() {
$scope.dtOptions.reloadData();
};
$scope.changeData = function() {
$scope.dtOptions.sAjaxSource = 'data1.json';
};
$scope.dtOptions = DTOptionsBuilder.fromSource('data.json').withPaginationType('full_numbers');
$scope.dtColumns = [
DTColumnBuilder.newColumn('id').withTitle('ID'),
DTColumnBuilder.newColumn('firstName').withTitle('First name'),
DTColumnBuilder.newColumn('lastName').withTitle('Last name').notVisible()
];
});