如何保留pickerInput liveSearch过滤器。现在,一旦做出选择,过滤器就会重置

时间:2019-07-16 06:33:38

标签: r shiny

一旦您在liveSearch中搜索了内容并从pickerInput下拉列表中选择了某个选项,liveSearch过滤器就会消失,并显示pickerInput的全部选择。

  

示例:假设我列出了许多水果和蔬菜,   在下拉菜单中进行选择,我只需要选择一些水果,所以我   在liveSearch中输入“水果”,我得到了Apple,Banana和Orange。   我需要选择Apple和Orange,所以我继续选择Apple   首先,但是这样做会重置liveSearch,而我剩下的是   整个列表。

library(shiny)
library(shinyWidgets)

ui <- fluidPage(
    fluidRow(
        column(12, br()),
        column(
            3,
            pickerInput(
                inputId = 'product_in', label = 'Select the products',
                multiple = TRUE,
                choices = c(
                    'Fruit_Apple', 'Fruit_Banana', 'Fruit_Orange',
                    'Vegetable_Broccoli', 'Vegetable_Cabbage', 'Vegetable_Lettuce'
                ),
                options = pickerOptions(
                    liveSearch = TRUE,
                    liveSearchPlaceholder = 'Search questions',
                    dropdownAlignRight = TRUE,
                    size = 5,
                    selectedTextFormat = 'count > 1',
                    countSelectedText = '{0} questions selected'
                )
            )
        ),
        column(9, verbatimTextOutput(outputId = "selectionOutput"))
    )
)

server <- function(input, output, session) {
    output$selectionOutput <- renderPrint({
        input$product_in
    })
}

# Run the application
shinyApp(ui = ui, server = server)

0 个答案:

没有答案