Skip to content

Speed up col reorder call #57

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
May 9, 2016
Merged

Conversation

719media
Copy link
Contributor

@719media 719media commented May 6, 2016

Doing a table.colReorder.order( [stuff], true ); for arrays with large length locks up the browser really bad. I've narrowed it down to the lines

var api = new $.fn.dataTable.Api( oSettings );
api.rows().invalidate();

I've moved these out and already the speed of doing this on my table of ~45 columns on my fairly new macbook pro went from ~8 seconds to around just over 1 second. I would imagine some other optimizations could be made if I took the time to understand the code more. Or at least issue in some timeouts to prevent the lock in. But it's a start?

Doing a table.colReorder.order( [stuff], true ); for arrays with large length locks up the browser really bad. I've narrowed it down to the lines

```javascript
var api = new $.fn.dataTable.Api( oSettings );
api.rows().invalidate();
```

I've moved these out and already the speed of doing this on my table of ~45 columns went from ~8 seconds to <1 second. I would imagine some other optimizations could be made if I took the time to understand the code more. But it's a start?
accidentally missed a commit you made earlier
@DataTables
Copy link
Collaborator

DataTables commented May 6, 2016

That looks like a good change - thanks! I probably wouldn't bother splitting the invalidate call into a separate plug-in API method for the legacy DataTables API (which I really need to upgrade ColReorder from), but rather just put it inline after the fnColReorder call.

I like that its backwards compatible as well - thanks!

One other thing - there is a change for the offset: var total = $(aoColumns[0].nTh).offset().left; - could you confirm what that is for? It looks like your PR might just be based off ColReorder from before 2383607.

Finally - are you happy for this to be included under the MIT license?

@DataTables
Copy link
Collaborator

Oops - I misread the second commit message ("comma" rather than "commit") - second my third paragraph above!

@719media
Copy link
Contributor Author

719media commented May 6, 2016

Yes that all sounds great of course. Thanks

Sent from my iPhone

On May 6, 2016, at 1:30 AM, Allan Jardine [email protected] wrote:

Oops - I misread the second commit message ("comma" rather than "commit") - second my third paragraph above!


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub

@DataTables DataTables merged commit 2586d97 into DataTables:master May 9, 2016
DataTables pushed a commit that referenced this pull request May 9, 2016
…ect API calls.

- ColReorder's code makes me want to cry...
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