Skip to contents

Push new rows to a shad_data_table() (replacing its data while keeping selection keys) and/or patch its interaction state.

Usage

update_shad_data_table(
  id,
  data = NULL,
  columns = NULL,
  row_key = NULL,
  selected = NULL,
  page = NULL,
  page_size = NULL,
  loading = NULL,
  session = shiny::getDefaultReactiveDomain()
)

Arguments

id

The input id (namespaced automatically).

data

Optional new data frame; sent via the table's setData().

columns

The shad_col() specs used when re-serializing data. Supply the same specs used at construction for consistent formatting.

row_key

Row-key column (as in shad_data_table()) for the new data.

selected

Optional character vector of row keys to select. A single-selection table ignores more than one key, with a browser console warning.

page, page_size

Optional pagination patch, as positive whole numbers. A page size the table does not offer is ignored, with a browser console warning, and a new page size starts at page 1. On a server-backed table (shad_data_table_server()) either one asks the server for that page.

loading

Optional logical to toggle the skeleton state.

session

The Shiny session.

Value

Invisibly NULL.

See also

Examples

if (interactive()) {
  ui <- page_shad(
    shad_button("Only four cylinders", inputId = "four"),
    shad_data_table("cars", mtcars)
  )
  server <- function(input, output, session) {
    shiny::observeEvent(input$four, {
      update_shad_data_table("cars", data = mtcars[mtcars$cyl == 4, ], page = 1)
    })
  }
  shiny::shinyApp(ui, server)
}