fnOrder() does not return new columns order after a drag'n'drop reordering

fnOrder() does not return new columns order after a drag'n'drop reordering

PierricPierric Posts: 2Questions: 0Answers: 0
edited April 2014 in Bug reports
Hi,

I've found a problem with the ColReorder extra : the fnOrder() method doesn't returns the correct order of the columns : it always returns the original order.

According to the documentation (http://datatables.net/extras/colreorder/api) :
[quote]" fnOrder [...] get the current order of the columns, as an array. Note that the values given in the array are unique identifiers for each column. Currently these are the original ordering of the columns that was detected on start up, but this could potentially change in future. "[/quote]

You can test it here : http://jsfiddle.net/Pierric/L7WpJ/25/
Here's the console log after 3 reorderings using drag'n'drop:
[code]
Original order = [0, 1, 2, 3, 4, 5, 6, 7]
Order after reordering : 0,1,2,3,4,5,6,7
Order after reordering : 0,1,2,3,4,5,6,7
Order after reordering : 0,1,2,3,4,5,6,7
[/code]

Is it a bug or am I missing something?

Many thanks. :-)

Replies

  • allanallan Posts: 63,494Questions: 1Answers: 10,470 Site admin
    The problem with the code there is that `new $.fn.dataTable.ColReorder(table)` is creating a new ColReorder instance each time. You can't have more than one on a table (I think the bug here really is that ColReorder should be throwing an error here...!).

    For example: http://jsfiddle.net/L7WpJ/26/

    Allan
  • PierricPierric Posts: 2Questions: 0Answers: 0
    Thank you very much Allan for this reply!... I'm sorry I suspected a bug when it was my own code that was suspect ;-)

    Pierric
This discussion has been closed.