das*_*i74 2 r input updates shiny
我的闪亮应用程序我有几个pickerInput元素.默认情况下,未选择任何内容.
pickerInput(
inputId = "pickerInput1",
label = NULL,
choices = c("Yes", "No"),
options = list(
`actions-box` = TRUE,
size = 12,
`selected-text-format` = "count > 3"
),
multiple = TRUE
)
Run Code Online (Sandbox Code Playgroud)
问题是我不知道如何在点击特殊按钮后清除所有这些(转到默认值).不幸的是我propobly不知道如何使用updatePickerInput.我试过了:
observeEvent(input$Clear_FilterButton, {
updatePickerInput(session, "pickerInput1", selected = NULL)
})
Run Code Online (Sandbox Code Playgroud)
但它不起作用:(任何想法我做错了什么?
如果您正在使用pickerInputfrom shinyWidgets,则设置actions-box为默认情况下TRUE应构建全选和取消全选按钮.你不需要updatePickerInput.单击您pickerInput可以看到这些按钮.
有关其他详细信息,请参阅文档:https:
//github.com/dreamRs/shinyWidgets
更新后续评论:
您的评论使问题更加明确.你可以简单地使用selected = ""而不是selected = NULL.这是一个工作示例:
library(shiny)
library(shinyWidgets)
ui <- fluidPage(
pickerInput(
inputId = "pickerInput1",
label = NULL,
choices = c("Yes", "No"),
options = list(
`actions-box` = TRUE,
size = 12
),
multiple = TRUE
),
actionButton(
inputId = "Clear_FilterButton",
label = "Clear"
)
)
server <- function(session, input, output) {
observeEvent(input$Clear_FilterButton, {
updatePickerInput(
session,
"pickerInput1",
selected = ""
)
})
}
shinyApp(ui = ui, server = server)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
560 次 |
| 最近记录: |