colReorder via button

colReorder via button

nicontrolsnicontrols Posts: 32Questions: 16Answers: 1

I have the following onclick:

$('.dropdown-view').on('click', function(e) {
    let order = [7,6,5,4,3,2,1,0];
    table.colReorder.order(order);        
});

This works great and reorders the columns from back to front.
I can also jumble them up:

    let order = [5,6,7,2,3,4,1,0];
    table.colReorder.order(order);       

However, I can never get them back to the original order. This does not work:

    let order = [0,1,2,3,4,5,6,7];
    table.colReorder.order(order);       

I can't see an error in the log. The table just doesn't reorder.

This question has an accepted answers - jump to answer

Answers

  • nicontrolsnicontrols Posts: 32Questions: 16Answers: 1

    I think I understand why this is now. I think the order is relative to the current order, not the original order.

    So let order = [0,1,2,3,4,5,6,7] does nothing because the order is already that.

  • colincolin Posts: 15,237Questions: 1Answers: 2,599
    Answer ✓

    Hi @nicontrols ,

    Yep, you can use colReorder.reset() to restore the original order.

    Cheers,

    Colin

  • nicontrolsnicontrols Posts: 32Questions: 16Answers: 1

    Thanks Colin!

This discussion has been closed.