本文介绍了R发光取消选中checkboxGroup with actionbutton的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有checkboxGroup选择的项目,和actionButton。我需要在actionButton点击取消选中checkBoxGroup。

  wellPanel(
checkboxGroupInput(datename,Select dates:,some_dates,
selected = outlier_dates_to_select),
actionButton(buttonname,Uncheck all)

任何建议,我该如何管理?



非常感谢!

解决方案

您必须使用 actionButton ,例如:



在ui.R中:

  shinyUI(pageWithSidebar(
headerPanel(title =),
sidebarPanel (
checkboxGroupInput(Test1,Test1,choices = c(1,2,3),selected =1),
checkboxGroupInput(Test2 Test2,choices = c(1,2,3),selected =2),
actionButton(Uncheck,label =Uncheck)
),
mainPanel()
))

而在server.R中:

  shinyServer(function(input,output,session){
observe({
if(input $ Uncheck& 0){
updateCheckboxGroupInput(session = session,inputId =Test1,choices = c(1,2,3),selected = NULL)
updateCheckboxGroupInput inputId =Test2,choices = c(1,2,3),selected = NULL)
}
})

您必须在 updateCheckboxGroupInput 中重复选择才能使其工作。 p>

I have checkboxGroup with selected items, and actionButton. I need on actionButton click uncheck checkBoxGroup.

          wellPanel(
             checkboxGroupInput(datename, "Select dates:", some_dates,
                                selected = outlier_dates_to_select),
             actionButton("buttonname", "Uncheck all")
        ) 

Any suggestions, how I can manage that?

Thank you a lot!

解决方案

You have to use actionButton like this for example :

In ui.R :

shinyUI(pageWithSidebar(
  headerPanel(title=""),
  sidebarPanel(
    checkboxGroupInput("Test1", "Test1", choices=c("1","2","3"), selected="1"),
    checkboxGroupInput("Test2", "Test2", choices=c("1","2","3"), selected="2"),
    actionButton("Uncheck", label="Uncheck")
  ),
  mainPanel()
))

And in server.R :

shinyServer(function(input, output, session) {
  observe({
   if (input$Uncheck > 0) {
      updateCheckboxGroupInput(session=session, inputId="Test1", choices=c("1","2","3"), selected=NULL)
      updateCheckboxGroupInput(session=session, inputId="Test2", choices=c("1","2","3"), selected=NULL)
   }
 })
})

You have to repeat choices in updateCheckboxGroupInput to make it work.

这篇关于R发光取消选中checkboxGroup with actionbutton的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 23:12