【发布时间】:2020-06-09 20:39:06
【问题描述】:
我正在我的 Shiny 应用程序中处理一个 DT,其中包含 Shiny Input 对象和一些可编辑的列。
这是一个可重现的例子,
library(shiny)
library(DT)
ui <- fluidPage(
fluidRow(
DTOutput('table1')
)
)
helper_fun <- function(FUN, len, id, ...) {
inputs = character(len)
for (i in seq_len(len)) {
inputs[i] = as.character(FUN(paste0(id, i), selected = 1, ...))
}
inputs
}
server <- function(input, output, session) {
output$table1 <- renderDT({
dat <- data.frame(Name = c('A', 'B')
, column1 = helper_fun(FUN = selectInput, len = length(2), id = 'selector_', label = NULL, choices = c(1, 2), width="100px")
)
dat
}, editable = list(target = 'cell', disable = list(columns = c(2))), server = FALSE, escape = FALSE
, options = list(preDrawCallback = JS('function() { Shiny.unbindAll(this.api().table().node()); }'),
drawCallback = JS('function() { Shiny.bindAll(this.api().table().node()); } ')))
}
shinyApp(ui, server)
我希望能够编辑 1 列并禁用对具有闪亮输入值的列的编辑。使用editable = list(target = 'cell', disable = list(column = c(2))) 不会产生预期的效果,因为这会禁用编辑,但在双击单元格时会暴露底层的html。
如何在某些列上禁用这种双击效果?
【问题讨论】: