Skip to content
This repository was archived by the owner on Feb 2, 2025. It is now read-only.

v0.4.0

Compare
Choose a tag to compare
@l-lin l-lin released this 23 Jan 22:34
· 504 commits to master since this release

Lots of changes in this release! :shipit:

  • The message event:loadedDT is no longer emitted. Instead, there is a new service DTInstances 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;
        });
    });
}

⚠️ This API is only available for the Ajax Renderer and Promise Renderer!

  • Expose method to rerender the entire directive #157
DTInstances.getLast().then(function (dtInstance) {
    dtInstance.rerender();
});

⚠️ 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. ⚠️

  • 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.

  • FixedColumns integration enhancement #142
  • FixedHeader support #196
  • Bug fixes:
    • Correction when rendering with the Angular way and when using a language url #181 #150
    • Issue about using Bootstrap with Scroller #189
    • Cannot change the options when using the Promise renderer #139 #172
    • Header can not be modified when datatable is filled from promise or ajax #149