英文:
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) %>%
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论