Reset sorting to default

Reset sorting to default

sboazsboaz Posts: 3Questions: 1Answers: 0

I currently have a table with default parameters, used via shiny DT module. I want to be able to sort along any column, which I can do by clicking on the column name. However, once I've done so, I am unable to return to the original sorting.
I do have a first column which shows indexes for each of the rows, but there's no column header for it, so I can't sort against it.

See attached image (Ignore the column X, it's an actual data column that it's not always there and only accidentally matches the row index for the shown cases.)

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,141Questions: 1Answers: 2,586

    As can be seen in this example here, you don't need a column heading to be able to apply the order. Have you disabled ordering on that column with columns.orderable?

    Colin

  • sboazsboaz Posts: 3Questions: 1Answers: 0

    @colin I want the columns to be orderable, but I also want the first column to be sortable as well. I haven't disabled anything. I just invoke DT::renderDataTable() on the data frame.

  • colincolin Posts: 15,141Questions: 1Answers: 2,586
    Answer ✓

    Could you look at my example above, please, and see if it helps. If it's still not working for you, please can you update my example, or link to your page, so that we can see the problem.

    Cheers,

    Colin

  • sboazsboaz Posts: 3Questions: 1Answers: 0

    @colin I confirm that there's a sorting_disabled class. This has probably nothing to do with datatables itself, but how R datatables package creates the table, so I'll ask there. Thank you for your help!

This discussion has been closed.