Maps the lengthMenu
selected value property of DT::datatable
to a shiny
variable.
Arguments
- dt_name
ns()
ofinputId
of theDT::datatable
- dt_rows
ns()
ofinputId
of the variable that holds the current selected value oflengthMenu
Value
(shiny::tagList
) A shiny tagList
.
Examples
library(shiny)
library(DT)
ui <- function(id) {
ns <- NS(id)
tagList(
DTOutput(ns("data_table")),
get_dt_rows(ns("data_table"), ns("dt_rows"))
)
}
# use the input$dt_rows in the Shiny Server function
server <- function(id) {
moduleServer(id, function(input, output, session) {
output$data_table <- renderDataTable(
{
iris
},
options = list(pageLength = input$dt_rows)
)
})
}
if (interactive()) {
shinyApp(
ui = ui("my_table_module"),
server = function(input, output, session) server("my_table_module")
)
}