if (interactive()) {
library(shiny)
library(periscope2)
library(reactable)
shinyApp(
ui = fluidPage(fluidRow(column(
width = 12,
downloadableReactTableUI(
id = "object_id1",
downloadtypes = c("csv", "tsv"),
hovertext = "Download the data here!")))),
server = function(input, output) {
table_state <- downloadableReactTable(
id = "object_id1",
table_data = reactiveVal(iris),
download_data_fxns = list(csv = reactiveVal(iris), tsv = reactiveVal(iris)),
selection_mode = "multiple",
pre_selected_rows = function() {c(1, 3, 5)},
table_options = list(columns = list(
Sepal.Length = colDef(name = "Sepal Length"),
Sepal.Width = colDef(filterable = TRUE),
Petal.Length = colDef(show = FALSE),
Petal.Width = colDef(defaultSortOrder = "desc")),
showSortable = TRUE,
theme = reactableTheme(
borderColor = "#dfe2e5",
stripedColor = "#f6f8fa",
highlightColor = "#f0f5f9",
cellPadding = "8px 12px")))
observeEvent(table_state(), { print(table_state()) })
})
}
Run the code above in your browser using DataLab