在showModal中使用textOutput

时间:2017-08-24 19:23:41

标签: r shiny modal-dialog

我正在尝试将textOutput添加到我的modalDialog中,但它无法正常工作。任何帮助,将不胜感激。我意识到这不是一个有效的例子,但应用程序非常庞大,而且我没时间创建一个迷你示例。我对modalDialog也缺乏经验。 除了textOutput之外,一切都按计划工作 - 它根本不显示。

library(tibble)
library(dplyr)
library(lubridate)
library(tidyr)
library(DT)
library(digest)
library(DBI)
library(shinyjs)
library(highcharter)
library(pool) #devtools::install_github("rstudio/pool")
library(shinyFeedback)
library(summaryrow)

showModal(
 modalDialog(
  fluidRow(
   column(
    width = 3,
    h1("Expense"),
    numericInput(
      inputId = ns("payment_expense_a"),
      label = "Expense Payment by A",
      value = 0
    ),
    numericInput(
      inputId = ns("payment_expense_b"),
      label = "Expense Payment by B",
      value = 0
    ),
    h4(
      textOutput("attorney_paid_total") #This is sum of A and B payments
    )
   )
   ...
  )
 )
)
...
output$attorney_paid_total <- renderText({    
  paste0("Total Attorney Paid: XXX") #This will be reactive
})
...

谢谢。

2 个答案:

答案 0 :(得分:1)

您应该使用output$expense_paid_total而不是output$attorney_paid_total作为textOutput ID。

您在代码中没有textOutput id = attorney_paid_total。因此我假设问题是textOutput的ID不正确,它应该是:

...
output$expense_paid_total <- renderText({    
  paste0("Total Attorney Paid: XXX") #This will be reactive
})
...

请下次提供reproducible example,没有它,没有人可以真正帮助解决您的问题,只需假设某事......

答案 1 :(得分:0)

根据this,我只需将其包装在ns()

h4(textOutput(ns("attorney_paid_total")))