Skip to content

Redraw bug fix+get current order api #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 29, 2012

Conversation

netj
Copy link
Contributor

@netj netj commented Nov 29, 2012

This is a bug fix and an API proposal.

@DataTables
Copy link
Collaborator

I think the new API method you suggest is a nice idea and that should certainly be included. Thanks.

For the destroy issue, I think a better solution might be to listen for the DataTables' destroy event and detach itself from all callbacks at that point. This is how TableTools does it: https://github.com/DataTables/TableTools/blob/master/media/js/TableTools.js#L676 .

Does that sound like it would cover the issue you were seeing?

@netj
Copy link
Contributor Author

netj commented Nov 29, 2012

That sounds better. I first tried looking for an easy way to remove the callbacks, but DataTables' API and the document were puzzling me. It seems TableTools isn't really removing any callbacks from DataTables side. I'll take a more thorough look and fix my commits.

- ColReorder's redraw callback was getting called sometimes after it has
  been destroyed, and this caused an error.  For instance, as DataTable
  gets destroyed, it first calls all the destroy callbacks, then tries
  to restore column visibility, but at that point, ColReorder's redraw
  callback gets triggered.
@DataTables
Copy link
Collaborator

Yeah the API documentation is very lacking in that area... :-(

TableTools doesn't really listen for callbacks from DataTables - just its own events, so it is slightly different. There isn't actually a _fnCallbackUnreg method in DataTables - so you'd probably need to loop over the arrays and remove the events that way. A bit messy, but something that is most certainly on my to-do list now!

- Without such API, the fnReorderCallback is not so useful.  Now, we can
  access the new column order array within the callback as follows:

	this.fnGetCurrentOrder()
@netj
Copy link
Contributor Author

netj commented Nov 29, 2012

The new way of removing callback works fine as my previous change. You can refactor my fix when you add a _fnCallbackUnreg later. I saw some callbacks being attached directly to the object instead of going through _fnCallbackReg, e.g., aoDrawCallback in ColReorder, so that maybe something you want to refactor as well.

@DataTables
Copy link
Collaborator

Agreed. Not a very desirable set of circumstances - but that's what happens with legacy code!

Merging in and noting for future enhancement.

Thanks for the contribution!

DataTables pushed a commit that referenced this pull request Nov 29, 2012
@DataTables DataTables merged commit 8f5a42f into DataTables:master Nov 29, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants