简体   繁体   English

Shiny + DT:单细胞选择

[英]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.

相关问题 闪亮-DT-跨多个DT :: table的单行选择 - Shiny - DT - Single row selection, across several DT::tables 通过 DT::datatable 的单个单元格选择对数据框进行子集 - Subset a dataframe by single cell selection of DT::datatable shiny DT,更新值后更改单元格颜色,不被选择覆盖 - shiny DT, change cell color after updated value, not overwritten by selection 在闪亮的仪表板中存储和打印基于多个 DT 行选择的单元格值 - Store and print cell values based on multiple DT row selection in a shiny dashboard Select 一个 DT 行,然后根据 shiny 应用程序中的小部件选择输入和 actionButton() 更改此行的一个单元格的值 - Select a DT row and then change the value of one cell of this row based on widget selection input and actionButton() in a shiny app 在Shiny R中重置DT :: renderDataTable()的行选择 - Reset row selection for DT::renderDataTable() in Shiny R 如何根据R Shiny DT中的模式突出显示一行中相邻单元格的串,每个单元格包含单个字符 - How to highlight bunch of adjacent cells in a row containing single character per cell based on a pattern in R Shiny DT 为 DT shiny 中的单列渲染下拉列表,但仅在单击单元格时加载并使用 replaceData() - render dropdown for single column in DT shiny BUT loaded only on cell click and with replaceData() 使用数据表单单元格选择在R Shiny中子集数据帧 - Use datatable single cell selection to subset a dataframe in R shiny 将 Shiny DT 单元格复制到用户剪贴板 - Copy a Shiny DT cell to users clipboard
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM