v0.4.0
Lots of changes in this release! ✨
- The message
event:loadedDT
is no longer emitted. Instead, there is a new serviceDTInstances
that provides the list of the DataTables that are instanciated #174.
You can fetch the instances like this:
DTInstances.getLast().then(function(lastDTInstance) {
// lastDTInstance === {"id": "foobar2", "DataTable": oTable, "dataTable": $oTable, "reloadData": fnReloadData, "changeData": fnChangeData}
// loadedDT.DataTable is the DataTable API instance
// loadedDT.dataTable is the jQuery Object
// See http://datatables.net/manual/api#Accessing-the-API
});
DTInstances.getList().then(function(dtInstances) {
/*
* dtInstances === {
* "foobar": {"id": "foobar2", "DataTable": oTable, "dataTable": $oTable, "reloadData": fnReloadData, "changeData": fnChangeData},
* "foobar2": {"id": "foobar2", "DataTable": oTable, "dataTable": $oTable, "reloadData": fnReloadData, "changeData": fnChangeData}
* }
*/
});
The clumsy API dtOptions.reload()
has been moved to the directive instance. Indeed, reloading data should not be on the options of the DT. It should rather be within the method of the instance of the directive.
Now, to reload the data, you will have to do it like this:
DTInstances.getLast().then(function(dtInstance) {
dtInstance.reloadData();
});
- Expose method to change the data:
angular.module('myModule', ['datatables']).controller('MyCtrl', MyCtrl);
function MyCtrl($resource, DTInstances) {
DTInstances.getLast().then(function(dtInstance) {
// For Ajax renderers
dtInstance.changeData('data.json');
// For Promise renderers
dtInstance.changeData(function() {
return $resource('data.json').query().$promise;
});
});
}
- Expose method to rerender the entire directive #157
DTInstances.getLast().then(function (dtInstance) {
dtInstance.rerender();
});
- Separate the plugins in different dist files #160
For example, if you need to add DataTables ColVis plugin support, then you will need to add the file angular-datatables/dist/plugins/colvis/angular-datatables.colvis.min.js
and your Angular needs to add a dependency to datatables.colvis
along with datatables
.