Enable comments in RHandsonTable but disable context menu?

Tags: #<Tag:0x00007f8b1da923b0>

I’m working with RHandsonTable and I want to add passive comments to several cells but I don’t want to have the context menu enabled (that allows user to add and remove rows, etc.). Is it possible to do this? Adding comments seems to automatically activate the contextMenu, and some of the context menu items can’t be disabled (in R at least).

library(rhandsontable)

vt <- mtcars
modrows <- c(3,6,9)
modtext <- LETTERS[1:3]
vttooltips <- matrix(ncol = ncol(vt), nrow = nrow(vt))
vttooltips[modrows, 2] <- modtext

rhandsontable(vt, 
              comments = vttooltips) %>% 
  hot_context_menu(allowRowEdit = FALSE, allowColEdit = FALSE, 
                   allowReadOnly = FALSE, allowComments = TRUE, 
                   allowCustomBorders = FALSE, customOpts = list())

Hi @woodward

I do not know R, but I think that I know what’s the issue.
Comments are activated by the comments plugin. You need to activate the comments (in JS you’d define it as true).
I have a demo https://jsfiddle.net/vh3xm4ys/ where I activate comments plugin (line 13) and then define the cell comment (line 18). As you can see when you click the RMB on the table the context menu is not accesible.

1 Like

Thanks so much! So it could be a limitation of rhandsontable I guess.

Here’s the solution, thank to @DzimitryM at
https://github.com/jrowen/rhandsontable/issues/334

t <- rhandsontable(vt, 
              comments = vttooltips)
t$x$contextMenu <- list()
t
1 Like