Dear Rstudio Community,
When using the interactive table of DT in Shiny, how to get the re-ordered column names in the server part?
There is a similar post: https://stackoverflow.com/questions/59428159/in-r-shinyproxy-how-do-i-get-the-order-of-columns-from-a-dtdatatable-after-a/59435181#59435181. But it only catches the new order of columns, and the new order is based on the last re-ordered columns rather than original columns. If original columns it is easy to get the answer.
library(shiny); library(DT)
if (interactive()) {
shinyApp(
ui = fluidPage(
fluidRow(column(12, dataTableOutput('table'))
)
),
server = function(input, output) {
output$table <- renderDataTable(datatable(iris, extensions=c('ColReorder', 'Scroller'), options=list(pageLength=5, colReorder=TRUE, scroller=TRUE))
)
}
)
}