| get_dt_rows | R Documentation |
lenghtMenu propertyMaps the lengthMenu selected value property of DT::datatable to a shiny variable.
get_dt_rows(dt_name, dt_rows)
dt_name |
|
dt_rows |
|
(shiny::tagList) A shiny tagList.
library(shiny)
library(DT)
ui <- function(id) {
ns <- NS(id)
tagList(
get_dt_rows(ns("data_table"), ns("dt_rows")),
textOutput(ns("rows")),
DT::DTOutput(ns("data_table"))
)
}
# use the input$dt_rows in the Shiny Server function
server <- function(id) {
moduleServer(id, function(input, output, session) {
output$data_table <- DT::renderDataTable(iris)
# Change rows selected to see the first line on the UI change
rows <- reactive({
paste0("Selected Rows ", input$dt_rows)
})
output$rows <- renderText(rows())
})
}
if (interactive()) {
shinyApp(
ui = ui("my_table_module"),
server = function(input, output, session) server("my_table_module")
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.