ColReorder ColVis issue
ColReorder ColVis issue
I've come across an issue when using the ColReorder plugin along with the column visibility Button.
It seems that the if you move a column multiple spaces over quickly something doesn't transition correctly and if you open the column visibility menu it doesn't match the order of the columns on screen and often appears to be pretty random.
If you then attempt to change the visibility of the column you've moved, the buttons relate to the matching column index not the matching column name. i.e. the 2nd Button will always change the visibility of the 2nd Column regardless of whether the button text says that is the one it relates to.
I've put a simple fiddle together here where I can reproduce the issue.
https://jsfiddle.net/fuzzyexponent/b2u438xw/
Answers
I've also just tried using the API rather than dragging the columns manually.
This can produce a similar effect where the visibility buttons don't match up to the display.
I've added a button to do this to the fiddle now.
After a bit of digging I believe the problem to be with this line of code.
Swapping
conf.columns = $.inArray( conf.columns, details.mapping );
forconf.columns = details.mapping[conf.columns];
When I went to post a pull request I found that someone beat me to it.
https://github.com/DataTables/Buttons/pull/159