'RHandsOnTable - Comment tracking
Comment changes are not exposed in inputs$hot$changes. Is there any other event we can observe for when a comment is created/edited along with its updated contents?
Solution 1:[1]
Like this:
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)
Looks like key is always "comment", so you can remove it. value also returns the width and the height of the comment box.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Stéphane Laurent |
