How to reset sort order

How to reset sort order

lenamtllenamtl Posts: 265Questions: 65Answers: 1
edited January 2019 in Free community support

Let say I have this
"order": [[ 10, "asc" ],[ 0, "asc" ], [ 6, "asc" ], [ 7, "asc" ],[ 8, "desc" ]],

and I'd like to have a button that reset only that

let say to this
"order": [ ],

I need this mostly because I have a lot of column that are hidden by responsive
so if a column have an ASC order and is hidden by responsive toggle there is no easy way to reset it.
the only solution is to hide previous column, now the column is visible and we can see that is ordered or not.

So i'd like to offer a quick way for the user to reset the all, or if possible per column that can be another solution.

Thanks

This question has an accepted answers - jump to answer

Answers

  • lenamtllenamtl Posts: 265Questions: 65Answers: 1
    edited January 2019

    Hi,
    I have tested using this table.order.neutral().draw();
    but it seem to reset to the initial value, what i want is no sort order is this possible?

    $('#resetsort').click( function() {
            table.order.neutral().draw();
        });
    
  • colincolin Posts: 15,142Questions: 1Answers: 2,586
    Answer ✓

    Hi @lenamtl ,

    As you can see here, when that order.neutral() is called, it does reset to the order that the original data is in. This is what I would expect. What do you mean by "no sort order"?

    Cheers,

    Colin

  • lenamtllenamtl Posts: 265Questions: 65Answers: 1
    edited January 2019

    ok yes it's working fine now..

    I'm wondering is this possible to reset per column only ?

    or to set a new value let say

    "order": [ 0, "desc" ],

    I may implement a sort panel ASC/DESC per column similar to the view/hide column
    (never see this, maybe someone have already implement this)

    As with responsive we don't have the ability to reorder by item that are hidden by the toggle... So if there is any other way I'd like to know how..

This discussion has been closed.