[英]Shiny + DT: Single Cell Selection
I am trying to use the development version of the DT package (available at devtools::install_github('rstudio/DT')
) to enable single cell selection in a shiny application. 我正在尝试使用DT软件包的开发版本(在
devtools::install_github('rstudio/DT')
可用)来启用闪亮应用程序中的单个单元格选择。 I have been able to make the selection be cells using the target
argument for selection
; 我已经能够使用
target
参数进行selection
; however, I can't figure out how to disable multiple cells being selected. 但是,我无法弄清楚如何禁用被选中的多个单元格。 Is there another argument for the
selection
parameter list that will allow me to restrict the user's selection to a max of 1 cell? 是否有
selection
参数列表的另一个参数,允许我将用户的选择限制为最多1个单元格? If not, is there another way to accomplish single cell selection? 如果没有,是否有另一种方法可以完成单细胞选择?
I am very open to revert back to the stable version of DT
on CRAN if there is an easier solution using that version of the package. 如果使用该版本的软件包有更简单的解决方案,我非常愿意在CRAN上恢复到稳定版本的
DT
。
library(shiny)
library(DT)
data("mtcars")
ui <- shinyUI(
fluidRow(
DT::dataTableOutput("myDatatable"),
verbatimTextOutput("selectedCells")
)
)
server <- shinyServer(function(input, output, session) {
output$myDatatable <- DT::renderDataTable(mtcars,
selection=list(target="cell"),
server = FALSE,
rownames=FALSE)
output$selectedCells <- renderPrint(input$myDatatable_cells_selected)
})
shinyApp(ui, server)
The problem is in your call to DT::renderDataTable
in the selection
list. 问题在于您在
selection
列表中调用DT::renderDataTable
。 You need selection=list(mode="single", target="cell")
你需要
selection=list(mode="single", target="cell")
mode
sets single or multiple where you had selection
(before your edit) mode
设置您selection
单个或多个(在编辑之前)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.