注释更改不会在inputs$hot$changes中公开。在创建/编辑注释及其更新的内容时,还有其他事件可以用于observe吗?
发布于 2022-04-18 00:48:07
如下所示:
library(shiny)
library(rhandsontable)
library(htmlwidgets)
jsCode <- c(
"function(el, x) {",
" Handsontable.hooks.add('afterSetCellMeta', function(row, col, key, value){",
" Shiny.setInputValue(",
" 'commentAction',",
" {row: row, col: col, key: key, value: value}",
" );",
" }, this.hot);",
"}"
)
ui <- fluidPage(
rHandsontableOutput("test")
)
server <- function(input, output, session) {
output[["test"]] <- renderRHandsontable({
rhandsontable(
data = data.frame(a = 1:2, b = 3:4),
comments = rbind(c("Hello!", "How"), c("are", "you?"))
) %>% onRender(jsCode)
})
observe({print(input[["commentAction"]])})
}
shinyApp(ui, server)看起来key总是"comment",所以您可以删除它。value还返回注释框的宽度和高度。
https://stackoverflow.com/questions/71886139
复制相似问题