Actionbutton 仅在 Selectinput 更改时显示
Actionbutton shown only when Selectinput changes
有没有办法让操作按钮仅在 Selectinput 更改时闪亮?例如,假设我从 selectinput 中选择了选项 A。此时操作按钮将被禁用,但是只要我在 A 之外添加选项 B(反之亦然,当您删除选项 B 时),操作按钮将再次显示以确认这些更改?对于没有提供可重现的示例,我提前表示歉意,因为我不知道如何处理它。
也许您正在寻找这个
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
selectInput("actionona", "actionbutton on demand", c("A", "B"), selected=1),
selectInput("actiondisableb", "Disable When D is selected", c("C", "D")),
fluidRow( uiOutput("action1"), uiOutput("action2"))
),
mainPanel(
uiOutput('myvalue1'),
uiOutput('myvalue2')
)
)
)
server <- function(input, output, session){
output$action1 <- renderUI({
if(input$actionona=="A"){
actionBttn(inputId="plotbtn",
label="Action One",
style = "simple",
color = "success",
size = "md",
block = FALSE,
no_outline = TRUE
)
}else{
return(NULL)
}
})
output$action2 <- renderUI({
req(input$actiondisableb)
if (is.null(input$actiondisableb)) {
return(NULL)
}
else {
actionBttn(inputId="plotmebtn",
label="Action Two",
style = "simple",
color = "primary",
size = "md",
block = FALSE,
no_outline = TRUE
)
}
})
observeEvent(input$plotbtn, {
req(input$plotbtn)
if (input$plotbtn==0) {
return(NULL)
}else {
output$myvalue1 <- renderUI({
if (input$actionona=="A") {
tagList(
p("Blah Blah Blah 1", style = "color:red")
)
}else {return(NULL)}
})
}
})
observeEvent(input$plotmebtn, {
req(input$actiondisableb,input$plotmebtn)
if (input$plotmebtn==0) {
return(NULL)
}else {
output$myvalue2 <- renderUI({
if (input$actiondisableb=="C") {
tagList(
p("Blah Blah Blah 2", style = "color:blue")
)
}else {return(NULL)}
})
}
})
}
shinyApp(ui = ui, server = server)
有没有办法让操作按钮仅在 Selectinput 更改时闪亮?例如,假设我从 selectinput 中选择了选项 A。此时操作按钮将被禁用,但是只要我在 A 之外添加选项 B(反之亦然,当您删除选项 B 时),操作按钮将再次显示以确认这些更改?对于没有提供可重现的示例,我提前表示歉意,因为我不知道如何处理它。
也许您正在寻找这个
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
selectInput("actionona", "actionbutton on demand", c("A", "B"), selected=1),
selectInput("actiondisableb", "Disable When D is selected", c("C", "D")),
fluidRow( uiOutput("action1"), uiOutput("action2"))
),
mainPanel(
uiOutput('myvalue1'),
uiOutput('myvalue2')
)
)
)
server <- function(input, output, session){
output$action1 <- renderUI({
if(input$actionona=="A"){
actionBttn(inputId="plotbtn",
label="Action One",
style = "simple",
color = "success",
size = "md",
block = FALSE,
no_outline = TRUE
)
}else{
return(NULL)
}
})
output$action2 <- renderUI({
req(input$actiondisableb)
if (is.null(input$actiondisableb)) {
return(NULL)
}
else {
actionBttn(inputId="plotmebtn",
label="Action Two",
style = "simple",
color = "primary",
size = "md",
block = FALSE,
no_outline = TRUE
)
}
})
observeEvent(input$plotbtn, {
req(input$plotbtn)
if (input$plotbtn==0) {
return(NULL)
}else {
output$myvalue1 <- renderUI({
if (input$actionona=="A") {
tagList(
p("Blah Blah Blah 1", style = "color:red")
)
}else {return(NULL)}
})
}
})
observeEvent(input$plotmebtn, {
req(input$actiondisableb,input$plotmebtn)
if (input$plotmebtn==0) {
return(NULL)
}else {
output$myvalue2 <- renderUI({
if (input$actiondisableb=="C") {
tagList(
p("Blah Blah Blah 2", style = "color:blue")
)
}else {return(NULL)}
})
}
})
}
shinyApp(ui = ui, server = server)