Skip to content

Commit

Permalink
Namespace events and add proper destuction
Browse files Browse the repository at this point in the history
  • Loading branch information
futpib committed Mar 30, 2017
1 parent 99d897f commit c6e5ead
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions dataTables.rowsGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ var RowsGroup = function ( dt, columnsForGrouping )
this.order = []

var self = this;
dt.on('order.dt', function ( e, settings) {
dt.on('order.dt.rowsGroup', function ( e, settings) {
if (!self.orderOverrideNow) {
self.orderOverrideNow = true;
self._updateOrderAndDraw()
Expand All @@ -101,35 +101,39 @@ var RowsGroup = function ( dt, columnsForGrouping )
}
})

dt.on('preDraw.dt', function ( e, settings) {
dt.on('preDraw.dt.rowsGroup', function ( e, settings) {
if (self.mergeCellsNeeded) {
self.mergeCellsNeeded = false;
self._mergeCells()
}
})

dt.on('column-visibility.dt', function ( e, settings) {
dt.on('column-visibility.dt.rowsGroup', function ( e, settings) {
self.mergeCellsNeeded = true;
})

dt.on('search.dt', function ( e, settings) {
dt.on('search.dt.rowsGroup', function ( e, settings) {
// This might to increase the time to redraw while searching on tables
// with huge shown columns
self.mergeCellsNeeded = true;
})

dt.on('page.dt', function ( e, settings) {
dt.on('page.dt.rowsGroup', function ( e, settings) {
self.mergeCellsNeeded = true;
})

dt.on('length.dt', function ( e, settings) {
dt.on('length.dt.rowsGroup', function ( e, settings) {
self.mergeCellsNeeded = true;
})

dt.on('xhr.dt', function ( e, settings) {
dt.on('xhr.dt.rowsGroup', function ( e, settings) {
self.mergeCellsNeeded = true;
})

dt.on('destroy.dt.rowsGroup', function ( e ) {
dt.off('.rowsGroup');
})

this._updateOrderAndDraw();

/* Events sequence while Add row (also through Editor)
Expand Down Expand Up @@ -271,7 +275,7 @@ $.fn.dataTable.RowsGroup = RowsGroup;
$.fn.DataTable.RowsGroup = RowsGroup;

// Automatic initialisation listener
$(document).on( 'init.dt', function ( e, settings ) {
$(document).on( 'init.dt.rowsGroup', function ( e, settings ) {
if ( e.namespace !== 'dt' ) {
return;
}
Expand Down

1 comment on commit c6e5ead

@ashl1
Copy link

@ashl1 ashl1 commented on c6e5ead Aug 26, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello!
Thanks for using my Datatables plugin. Don't you think make a PR as I can see your changes solves issue #13 ?
Have you tested this with multiple Datatables tables with enabled ordering on one page?

Please sign in to comment.