1
2つのアクションボタンSelect All
とDeselect All
が作成されました。何らかの理由でDeselect All
が動作しますが、Select All
はではありません。「すべて選択」アクションボタンが機能しません
なぜですか? Deselect All
ボタンは、期待どおりにすべての行のハイライトを解除します。ただし、Select All
ボタンは何もしません。
は誰も助けることができる(TEMP
タブに示されているように)
input$selectAll
とinput$deselectAll
DATASET:
colA <- c('A','B','C','D','E')
colB <- c(1,2,3,4,5)
rawdata <- as.data.frame(cbind(colA,colB))
View(rawdata)
server.R
function(input, output, session) {
# Update summaryTable When users click 'Select All'
summaryTable <- eventReactive (input$selectAll,{
print("SelectAll")
DT::datatable(rawdata, selection = list(target = 'row', selected = c(1:ncol(rawdata()))))
})
# Update summaryTable When users click 'Deselect All'
summaryTable <- eventReactive (input$deselectAll,{
print("deselectAll")
DT::datatable(rawdata, selection = list(target = 'row', selected = c(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 {
summaryTable()
}
})
output$temp <- renderPrint({
print(input$selectAll)
print(input$deselectAll)
})
}
ui.R
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"))
)
)
)
Uは、列または行を選択したいと適切であると
nrow
にncol
を変更したことに注意してください? –