user1769197
user1769197

Reputation: 2213

R Shiny: how do i make the datatable display the last page on every reactive update?

How do I make the below always display the last page of the table instead of the first page on every reactive update ?

output$myTable <- DT::renderDataTable(datatable(df) %>% formatRound(c(2:5),2))

Note that reversing the order of the table is not what i wanted.

What I want is that when i start the app, it will bring me to the last page of the table always.

Upvotes: 1

Views: 324

Answers (1)

jhk0530
jhk0530

Reputation: 169

reverse order

Use order option to show table as "reverse" ordered.

https://rstudio.github.io/DT/options.html


Edit : added page to last

I'm not sure difference about reverse order and page to last.

but page to last can be achieved by using callback.

refer these

Here's minimal reproducible example.

library(DT)
datatable(
  data.frame(a = 1:50, b = 1:50 * 2),
  callback = JS(
    'table.page("last").draw(false);'
  )
)

Regards.

Upvotes: 2

Related Questions