R &引用;选择全部";操作按钮没有';行不通
我创建了两个操作按钮R &引用;选择全部";操作按钮没有';行不通,r,shiny,shiny-reactivity,R,Shiny,Shiny Reactivity,我创建了两个操作按钮全选和全选。由于某些原因,取消选择所有起作用,但选择所有不起作用 为什么呢?取消选择所有按钮按预期取消所有行的高亮显示。但是,全选按钮不起任何作用 input$selectAll和input$deselectAll已正确更新(如TEMP选项卡所示) 有人能帮忙吗?这是我的密码。谢谢 数据集: colA <- c('A','B','C','D','E') colB <- c(1,2,3,4,5) rawdata <- as.data.frame(cbind(c
全选
和全选
。由于某些原因,取消选择所有
起作用,但选择所有
不起作用
为什么呢?取消选择所有
按钮按预期取消所有行的高亮显示。但是,全选按钮不起任何作用
input$selectAll
和input$deselectAll
已正确更新(如TEMP
选项卡所示)
有人能帮忙吗?这是我的密码。谢谢
数据集:
colA <- c('A','B','C','D','E')
colB <- c(1,2,3,4,5)
rawdata <- as.data.frame(cbind(colA,colB))
View(rawdata)
这是你想要的吗?请注意,我将ncol
更改为nrow
,因为SelecteAll适合于行
library(shiny)
colA <- c('A','B','C','D','E')
colB <- c(1,2,3,4,5)
rawdata <- as.data.frame(cbind(colA,colB))
ui <- fluidPage(
mainPanel(
tabsetPanel(id = "allResults",
tabPanel(value='inputVars',title='Variable Selection',
verticalLayout(
DT::dataTableOutput('inputVars'),
br(),
fluidRow(align="bottom",
column(2, actionButton("selectAll" , strong("Select All"))),
column(3, actionButton("deselectAll", strong("Deselect All")))
)
)
),
tabPanel(value='temp',title="TEMP", verbatimTextOutput("temp"))
)
)
)
server <- function(input, output, session) {
var <- reactiveValues()
observeEvent(input$selectAll,{
print("SelectAll")
var$selected <- 1:nrow(rawdata)
})
observeEvent(input$deselectAll,{
print("deselectAll")
var$selected <- 0
})
# Default SummaryTable
output$inputVars <- DT::renderDataTable({
if (input$selectAll==0 & input$deselectAll==0) {
print("Default")
DT::datatable(rawdata, options = list(paging = FALSE, searching = FALSE))
}
else {
DT::datatable(rawdata, selection = list(target = 'row', selected = var$selected))
}
})
}
shinyApp(ui = ui, server = server)
库(闪亮)
可乐这就是你想要的吗?请注意,我将ncol
更改为nrow
,因为SelecteAll适合于行
library(shiny)
colA <- c('A','B','C','D','E')
colB <- c(1,2,3,4,5)
rawdata <- as.data.frame(cbind(colA,colB))
ui <- fluidPage(
mainPanel(
tabsetPanel(id = "allResults",
tabPanel(value='inputVars',title='Variable Selection',
verticalLayout(
DT::dataTableOutput('inputVars'),
br(),
fluidRow(align="bottom",
column(2, actionButton("selectAll" , strong("Select All"))),
column(3, actionButton("deselectAll", strong("Deselect All")))
)
)
),
tabPanel(value='temp',title="TEMP", verbatimTextOutput("temp"))
)
)
)
server <- function(input, output, session) {
var <- reactiveValues()
observeEvent(input$selectAll,{
print("SelectAll")
var$selected <- 1:nrow(rawdata)
})
observeEvent(input$deselectAll,{
print("deselectAll")
var$selected <- 0
})
# Default SummaryTable
output$inputVars <- DT::renderDataTable({
if (input$selectAll==0 & input$deselectAll==0) {
print("Default")
DT::datatable(rawdata, options = list(paging = FALSE, searching = FALSE))
}
else {
DT::datatable(rawdata, selection = list(target = 'row', selected = var$selected))
}
})
}
shinyApp(ui = ui, server = server)
库(闪亮)
是否要选择列或行?是否要选择列或行?
library(shiny)
colA <- c('A','B','C','D','E')
colB <- c(1,2,3,4,5)
rawdata <- as.data.frame(cbind(colA,colB))
ui <- fluidPage(
mainPanel(
tabsetPanel(id = "allResults",
tabPanel(value='inputVars',title='Variable Selection',
verticalLayout(
DT::dataTableOutput('inputVars'),
br(),
fluidRow(align="bottom",
column(2, actionButton("selectAll" , strong("Select All"))),
column(3, actionButton("deselectAll", strong("Deselect All")))
)
)
),
tabPanel(value='temp',title="TEMP", verbatimTextOutput("temp"))
)
)
)
server <- function(input, output, session) {
var <- reactiveValues()
observeEvent(input$selectAll,{
print("SelectAll")
var$selected <- 1:nrow(rawdata)
})
observeEvent(input$deselectAll,{
print("deselectAll")
var$selected <- 0
})
# Default SummaryTable
output$inputVars <- DT::renderDataTable({
if (input$selectAll==0 & input$deselectAll==0) {
print("Default")
DT::datatable(rawdata, options = list(paging = FALSE, searching = FALSE))
}
else {
DT::datatable(rawdata, selection = list(target = 'row', selected = var$selected))
}
})
}
shinyApp(ui = ui, server = server)