Example:
Following shiny example app.R
file contains a selectizeInput
UI. The selected elements can be removed by using options = list(plugins= list('remove_button'))
.
library(shiny)
library(dplyr)
ui= fluidPage(
sidebarLayout(
sidebarPanel(
selectizeInput(inputId= "cyl", label= "cyl",
choices= sort(unique(mtcars$cyl)),
selected= sort(unique(mtcars$cyl)),
multiple=T,
options = list(plugins= list('remove_button')))
),
mainPanel(
tableOutput("tab")
)
)
)
server= function(input, output) {
df_filtered= reactive({
mtcars %>%
{if (is.null(input$cyl)) . else filter(., cyl %in% input$cyl)}
})
output$tab= renderTable(df_filtered())
}
shinyApp(ui, server)
Question:
Is there an selectize.js option accessible in shiny which adds a feature "remove all-at-once" instead of the "remove one-by-one" as shown in the example?
I studied the selectize.js docu but got stuck.
remove_button
feature is relatively new, and there are not very many plug-ins at all yet. If someone was ambitious they could write a new plug in to do it of course, but it feels like it would be messy code. – Mike Wise