0
我有R閃存代碼問題,當我想要在複選框中看到真或假值時,我必須做什麼?因爲當我嘗試打印(輸入$行1)結果是NULL,並且當我給複選框檢查打印語句中沒有響應。這是代碼:閃亮 - 檢查數據表中的複選框時爲true或false值
library(shiny)
library(DT)
mymtcars = mtcars
mymtcars$id = 1:nrow(mtcars)
runApp(
list(ui = pageWithSidebar(
headerPanel('Examples of DataTables'),
sidebarPanel(
),
mainPanel(
uiOutput("mytable")
)
)
, server = function(input, output, session) {
output$mytable = renderUI({
addCheckboxButtons <- paste0('<input type="checkbox" id="row', mymtcars$id, '">',"")
yyy<- cbind(mymtcars[, names(mymtcars[,2:4]), drop=FALSE],Pick=addCheckboxButtons)
#try
print(input$row1) #didnt work
print(input$row2) #didnt work
#Display table with checkbox buttons
list(
renderDataTable(yyy,
options = list(orderClasses = TRUE,
lengthMenu = c(5, 25, 50),
pageLength = 25,
callback = JS("function(table) {
table.on('change.dt', 'tr td input:checkbox', function() {
setTimeout(function() {
Shiny.onInputChange('rows', $(this).add('tr td input:checkbox:checked').parent().siblings(':last-child').map(function() {
return $(this).text();
}).get())
}, 10);
});
}")),escape = FALSE
))
}
)
}
)
)