Bug: The colReorder.move(pos_1, pos_2) does not update the data-column-index for each of the 'th'
Bug: The colReorder.move(pos_1, pos_2) does not update the data-column-index for each of the 'th'
The colReorder.move() does not update the data-column-index accordingly - when the value tags are inspected after the move method is called, i.e visually the columns change positions however this is inconsistent with the data-column-index values under inspection. Thus causing further issues when working with the positioning in any other way.
Try testing this by initializing a basic DataTable with colReorder and somewhere in the js call the move method to relocate a column. Then inspect and observe the values of the data-column-index. Additionally, try dragging and observe the change of the data-column-index values. To make things more interesting try using the Column Visibility option to see the inconsistency of the positions when certain columns are removed from the visibility.
This question has an accepted answers - jump to answer
Answers
Thanks for posting this. I've added it as an issue for ColReorder so I don't forget to fix it before the next release.
Allan
Thank you for the response Allan
I have been trying to work around this issue using colReorder.transpose() but it is messy. Is it likely there may be a fix for this issue in early 2018?
I'll post back here whenever I get a chance to fix it. I can't say for sure when, as I've got a fair old back log at the moment, but I will try to get it done as soon as I can.
Allan
Thanks for the update Allan.
What fixed this for me for colReorder version 1.4.1 was to add
$.fn.dataTable.Api( this.s.dt ).rows().invalidate();
in the colReorder 'fnOrder' method. See code sample below: