nee*_*elp 1 r shiny selectize.js
我有一个自定义的selectizeInput地方,我使用 options 参数指定可用的选择(以进行自定义渲染和搜索,为简单起见,在示例中省略了)。现在我陷入了设置选定值的简单任务。从文档来看,这应该可以使用该items字段,但我正在努力寻找正确的方法来设置它。
library(shiny)
library(purrr)
choices <- purrr::transpose(list(x = letters[1:5],
y = LETTERS[1:5]))
ui <- fluidPage(
selectizeInput("select", 'Select', choices = "",
selected = "",
options = list(
valueField = 'x',
labelField = 'y',
items = choices[[1]],
options = choices
))
)
shinyApp(ui, function(input, output, session) {})
Run Code Online (Sandbox Code Playgroud)
可能有更好的选择,但这似乎可行。在 中添加以下内容options:
onInitialize = I('function() { this.setValue("a"); }')
Run Code Online (Sandbox Code Playgroud)
并参见“6.占位符”下图库selectize中的示例:shiny
https://shiny.rstudio.com/gallery/selectize-examples.html
ui <- fluidPage(
selectizeInput("select", 'Select', choices = "",
selected = "",
options = list(
valueField = 'x',
labelField = 'y',
#items = choices[[1]],
onInitialize = I('function() { this.setValue("a"); }'),
options = choices
))
)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2320 次 |
| 最近记录: |