inst/examples/DT-reload/app.R

library(shiny)
library(DT)
shinyApp(
  ui = fluidPage(
    fluidRow(
      column(2, actionButton('refresh', 'Refresh Data', icon = icon('refresh'))),
      column(10, DT::dataTableOutput('foo'))
    )
  ),

  server = function(input, output, session) {

    df = iris
    n = nrow(df)
    df$ID = seq_len(n)

    loopData = reactive({
      input$refresh
      df$ID <<- c(df$ID[n], df$ID[-n])
      df
    })

    output$foo = DT::renderDataTable(isolate(loopData()))

    proxy = dataTableProxy('foo')

    observe({
      replaceData(proxy, loopData(), resetPaging = FALSE)
    })
  }
)

Try the DT package in your browser

Any scripts or data that you put into this service are public.

DT documentation built on Oct. 5, 2023, 5:09 p.m.