提问人:Village.Idyot 提问时间:1/21/2023 更新时间:1/21/2023 访问量:24
在运行 jsTreeR 以构建层次结构树时,有没有办法对显示的节点进行着色或以其他方式在视觉上区分?
Is there a way to shade or otherwise visually differentiate displayed nodes when running jsTreeR for building hierarchy trees?
问:
当运行底部发布的代码时,用户可以将子元素从“菜单”父节点向下拖动到下面的另一个节点,以接收拖动的项目(“>> 拖到这里<<”),从而构建自定义层次结构树。
我正在尝试着色或以其他方式区分(例如,通过在周围绘制一个框),该节点会随着自定义层次结构树的变化而扩展/收缩。这怎么能做到呢?阴影将是我的偏好,但我对任何想法都持开放态度!
如下图所示:
法典:
library(jsTreeR)
library(shiny)
nodes <- list(
list(
text = "Menu",
state = list(opened = TRUE),
children = list(
list(text = "Dog",type = "moveable",state = list(disabled = TRUE)),
list(text = "Cat",type = "moveable",state = list(disabled = TRUE))
)
),
list(text = ">> Drag here <<",type = "target",state = list(opened = TRUE))
)
dnd <- list(
always_copy = TRUE,
inside_pos = "last",
is_draggable = JS(
"function(node) {",
" return node[0].type === 'moveable';",
"}"
)
)
mytree <-
jstree(
nodes, dragAndDrop = TRUE, dnd = dnd,
types = list(moveable = list(), target = list())
)
ui <- fluidPage(fluidRow(jstreeOutput("mytree")))
server <- function(input, output, session){
output[["mytree"]] <- renderJstree(mytree)
}
shinyApp(ui, server)
答: 暂无答案
评论