【发布时间】:2020-06-12 09:52:02
【问题描述】:
在我闪亮的应用程序中为 DT 渲染文本输入时,我遇到了一些非常奇怪的问题。 textinput 存储一些值,用作应用程序的设置之一。这些设置存储在响应式列表中,其中一个列表成员是 data.table - 存储所有渲染设置。
我做了一个可重现的例子,而不是代码 sn-ps。不漂亮,但它说明了。
library(shiny)
rv = reactiveValues()
ui <- shinyUI(fluidPage(
textInput(inputId = "textinput", label = h3("Numeric input"), value = "some value"),
tags$hr(),
fluidRow(column(3, verbatimTextOutput("textinput"))),
tags$hr(),
tabPanel("Settings table for viewing", dataTableOutput('settings_table')),
))
server <- function(input, output, session) {
observe({
# lst_names = list()
# lst_values = list()
rv$textinput <- renderText( input$textinput )
output$textinput <- renderText({ input$textinput }) # this is displayed nicely
# lst_names = c(lst_names, "rv$textinput")
# lst_values = c(lst_values, rv$textinput)
rv$settings = data.table(Var_names = "rv$textinput", Var_values = rv$textinput)
})
output$settings_table = DT::renderDataTable(options = list(pageLength = 50), {
rv$settings
})
}
shinyApp(ui, server)
我在 DT 的 github 中找到了这段文字,但我无法找到让它工作的方法。 与 numericinput、rendertext、renderprint、将 rendertext/print 移出“观察”块相同的问题。
有什么建议吗?
【问题讨论】:
-
用reproducible example帮助你会更容易
-
为什么
"rv$textinput"在引号中? -
@bretauv:已添加。 Pork Chop:它是设置的名称,旁边有值。