
Group of mutually dependent select menus for filtering data.frame
's columns (like in Excel).
select_group_ui(
id,
params,
label = NULL,
btn_reset_label = "Reset filters",
inline = TRUE,
vs_args = list()
)select_group_server(id, data_r, vars_r)
A shiny::reactive()
function containing data filtered with an attribute inputs
containing a named list of selected inputs.
Module's id.
A list of parameters passed to each shinyWidgets::virtualSelectInput()
,
you can use :
inputId
: mandatory, must correspond to variable name.
label
: Display label for the control.
placeholder
: Text to show when no options selected.
Character, global label on top of all labels.
Character, reset button label. If NULL
no button is added.
If TRUE
(the default),
select menus are horizontally positioned, otherwise vertically.
Arguments passed to all shinyWidgets::virtualSelectInput()
created.
Either a data.frame()
or a shiny::reactive()
function returning a data.frame
(do not use parentheses).
character, columns to use to create filters,
must correspond to variables listed in params
. Can be a
shiny::reactive()
function, but values must be included in the initial ones (in params
).
# Default -----------------------------------------------------------------
library(shiny)
library(datamods)
library(shinyWidgets)
ui <- fluidPage(
# theme = bslib::bs_theme(version = 5L),
fluidRow(
column(
width = 10, offset = 1,
tags$h3("Filter data with select group module"),
shinyWidgets::panel(
select_group_ui(
id = "my-filters",
params = list(
list(inputId = "Manufacturer", label = "Manufacturer:"),
list(inputId = "Type", label = "Type:"),
list(inputId = "AirBags", label = "AirBags:"),
list(inputId = "DriveTrain", label = "DriveTrain:")
), vs_args = list(disableSelectAll = FALSE)
),
status = "primary"
),
reactable::reactableOutput(outputId = "table"),
tags$b("Inputs values:"),
verbatimTextOutput("inputs")
)
)
)
server <- function(input, output, session) {
res_mod <- select_group_server(
id = "my-filters",
data = reactive(MASS::Cars93),
vars = reactive(c("Manufacturer", "Type", "AirBags", "DriveTrain"))
)
output$table <- reactable::renderReactable({
reactable::reactable(res_mod())
})
output$inputs <- renderPrint({
attr(res_mod(), "inputs")
})
}
if (interactive())
shinyApp(ui, server)
Run the code above in your browser using DataLab