Shiny + DT:单细胞选择

Ada*_*uer 4 r shiny dt

我正在尝试使用DT软件包的开发版本(可用devtools::install_github('rstudio/DT'))在闪亮的应用程序中启用单个单元格选择.我已经能够使用target参数for 选择为单元格selection; 但是,我无法弄清楚如何禁用被选中的多个单元格.是否有selection参数列表的另一个参数允许我将用户的选择限制为最多1个单元格?如果没有,是否有另一种方法可以完成单细胞选择?

DT如果使用该版本的软件包有更简单的解决方案,我非常愿意恢复到CRAN 的稳定版本.

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)
Run Code Online (Sandbox Code Playgroud)

Mar*_*ark 8

问题在于您DT::renderDataTableselection列表中的调用.你需要selection=list(mode="single", target="cell")

mode设置您拥有的单个或多个selection(在编辑之前)