如何在可排序的软件包中制作标签add_rank_list函数反应性?
在运行以下MWE代码时,用户将项目从左侧的面板拖到右侧的面板。请注意,当项目从左侧“拖动”面板中拖动时,列出的列表会耗尽。是否可以使这些列表元素(在 labels中定义= C(...)
在下面的第一个 add_rank_list()
函数下面)反应性,以便列表永远不会在此示例中,耗尽,始终包含A,B,C,D,E,无论该项目被拖过了多少次?换句话说,用户每次将项目拖到右侧,观察者会被触发,并且再次生成A,B,C,D,E的同一列表?
这类似于可排序软件包中可用的克隆功能,除了我知道克隆不能使用更简单的 bucket_list(add_rank_list(...))
andtax使用。
MWE:
library(shiny)
library(sortable)
ui <- fluidPage(htmlOutput("rankingForm"))
server <- function(input, output, session) {
output$rankingForm <- renderUI({
fluidRow(
br(),
column(tags$b("Ranking"), width = 12,
bucket_list(header = "Drag items to the right panel:",
group_name = "bucket_list_group", orientation = "horizontal",
add_rank_list("Drag from Pool:",
labels = c("A","B","C","D","E"), # make labels reactive?
input_id = "rank_list_1"),
add_rank_list("Drag to:", labels = NULL,
input_id = "rank_list_2"))
)
)
})
}
shinyApp(ui=ui, server=server)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
经过进一步的研究,似乎无法与简化函数
bucket_list(add_rank_list(...))
一起使用克隆功能,但是当前必须与sortable_js(... )
。更改允许在更简单的代码中允许使用“可排序软件包”开发人员的更改,请参见 https://github.com/rstudio/sortable/sissues/45 。但是,通过下面列出的相关帖子,Stackoverflow用户群已经足够友好,可以通过
sortable_js()
来指导我解决问题。请参阅底部的“工作解决方案代码”。相关解决方案帖子:
来自HTML/CSS的元素以及R数据框架?和
态订购编号为这个简单的可排序示例?
和一个重要链接解释克隆:
工作解决方案代码:
After further research, it seems that the cloning feature can't be used with the simplified functions
bucket_list(add_rank_list(...))
, but must currently be used withsortable_js(...)
. A change to allow this feature in the simpler code has been requested of the sortable package developer, see vladimir_orbucina request at https://github.com/rstudio/sortable/issues/45.Nevertheless through related posts listed below, the StackOverflow user base has been kind enough to guide me through
sortable_js()
features that resolve the question. See "Working solution code" at the bottom.Related solution posts:
How to pull list elements from HTML/CSS and into an R data frame? and
Any creative ways to add rank ordering numbering to this simple sortable package example?
And an important link explaining cloning: https://rstudio.github.io/sortable/articles/cloning.html
Working solution code: