定义rhandsontable中contextMenu的自定义项目

huangapple go评论67阅读模式
英文:

Defining custom items in the contextMenu for rhandsontable in R

问题

以下是翻译好的内容:

我正在尝试在R中为rhandsontable定义上下文菜单的自定义项目,按照Handsontable文档的说明。但是,我遇到了一个错误。这是我尝试的代码:

library(rhandsontable)
library(magrittr)

rhandsontable(iris) %>% hot_table(contextMenu = list(items = list('col_left', 'col_right')))

这段代码产生了以下错误:

Error in !is.null(contextMenu) && contextMenu : 
  invalid 'y' type in 'x && y'

我找到了一个相关的GitHub问题,可能会提供一些见解,但我仍然无法解决这个问题。如何可以正确地定义rhandsontable的上下文菜单中的自定义项目?


编辑:
为了更好理解,我正在Shiny中使用这个脚本。也许我们可以通过一些JavaScript直接操作上下文菜单?

英文:

I am trying to define custom items in the contextMenu for rhandsontable in R, following the Handsontable documentation. However, I am encountering an error. Here's the code I have tried:

library(rhandsontable)
library(magrittr)

rhandsontable(iris) %>% hot_table(contextMenu = list(items = list('col_left', 'col_right')))

This code produces the following error:

Error in !is.null(contextMenu) && contextMenu : 
  invalid 'y' type in 'x && y'

I found a related GitHub issue that may provide some insight, but I am still unable to resolve the problem. How can I correctly define custom items in the contextMenu for rhandsontable?


Edit:
For context, I am using this script in Shiny. Perhaps we can directly manipulate the contextMenu via some javascript?

答案1

得分: 1

I don't have a mouse and the right-click does not work on my pad, so I can't try. I would try:

rhandsontable(iris, useTypes = FALSE) %>%
  hot_context_menu(customOpts = list(items = list("col_left", "col_right")))

or

hot <- rhandsontable(iris, useTypes = FALSE)
hot$x$contextMenu = list(items = list("col_left", "col_right"))

EDIT

My pad works sometimes, I have been able to check and the second code works.

英文:

I don't have a mouse and the right-click does not work on my pad, so I can't try. I would try:

rhandsontable(iris, useTypes = FALSE) %&gt;% 
  hot_context_menu(customOpts = list(items = list(&quot;col_left&quot;, &quot;col_right&quot;)))

or

hot &lt;- rhandsontable(iris, useTypes = FALSE)
hot$x$contextMenu = list(items = list(&quot;col_left&quot;, &quot;col_right&quot;))

EDIT

My pad works sometimes, I have been able to check and the second code works.

huangapple
  • 本文由 发表于 2023年3月31日 04:08:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/75892567.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定