在主应用程序中使用renderUI或InsertUI时,闪亮模块服务器中的输入未更新

在主应用程序中使用renderUI或InsertUI时,闪亮模块服务器中的输入未更新,r,shiny,shinymodules,R,Shiny,Shinymodules,我的应用程序既可以生成自动Ui,也可以手动添加Ui。我在主应用程序中使用了renderUI和InsertUI来调用闪亮的模块 shiny模块的正常使用情况是,即使模块服务器中有renderUI函数,也能很好地更新我的值。但是,当我通过调用insertUI和renderUI函数生成闪亮的模块时,输入值(selectInput、NumericiInput)不会更新。我不明白原因,有人能回答我的问题吗 这是我的可行代码 观察模块更新输入时出现问题 # Module UI ui_module &l

我的应用程序既可以生成自动Ui,也可以手动添加Ui。我在主应用程序中使用了renderUI和InsertUI来调用闪亮的模块

shiny模块的正常使用情况是,即使模块服务器中有renderUI函数,也能很好地更新我的值。但是,当我通过调用insertUI和renderUI函数生成闪亮的模块时,输入值(selectInput、NumericiInput)不会更新。我不明白原因,有人能回答我的问题吗

这是我的可行代码

观察模块更新输入时出现问题

# Module UI

  ui_module <- function(id){
  ns <- NS(id)

  fluidRow(
         uiOutput(ns("Input_ui"))
          )
   }

# Server UI

 server_module <- function(input,output,session){
  ns <- session$ns

   output$Input_ui <- renderUI({
     list(
       tags$div(id = ns("input_div"),numericInput(ns("Input"),"Number",NA,value = 537153, step = 1)),
       tags$div(id = ns("input2_div"),numericInput(ns("Input2"),"Number2",NA,value=686575,step = 1))
     )
  })

## INPUTS are not updating ##

 observe({
      updateNumericInput(session,
                     "Input", "Number",value = 4, step = 1)
      updateNumericInput(session,
                      "Input2", "Number2",value = 8.9, step = 1)
   })
 }

 # App UI

 ui <- fluidPage(
    fluidRow(id = "Row",
      uiOutput("ui"),
      actionButton("add","ADD")
    )
  )

# Server UI

 server <- function(input,output,session){
 # Initiating counter 
   n <- 0
 # One by one adding the modules

       observeEvent(input$add,{
             n <<- n + 1
             panels <- paste0("panels_new",n)
             insertUI("#Row",
                      "beforeEnd",
                       ui_module(panels))

             callModule(server_module,panels)
         })

  # Generating a no of shiny modules based on the some table rows

   output$ui <- renderUI({
           n <- 2                                # n will be nrow in my main app.
           list <- as.list(1:n)
           lapply(list, function(i){
                panels <- paste0("panels",i)
             fluidRow(
                 ui_module(panels)
         )
       })
     })

   observe({
           n <- 2                                # n will be nrow in my main app.
           list <- as.list(1:n)
           lapply(list, function(i){
           panels <- paste0("panels",i)
           callModule(server_module,panels)
    })
  })
 }

shinyApp(ui,server)
#模块用户界面
ui_模块
  • 模块服务器函数没有返回任何内容,因此 服务器模块不知道有任何更改
  • 您不需要在模块服务器函数中为输入命名名称空间。他们是 已命名
  • 您想更新什么以及何时更新?一点也不清楚
      • 模块服务器函数没有返回任何内容,因此 服务器模块不知道有任何更改
      • 您不需要在模块服务器函数中为输入命名名称空间。他们是 已命名
      • 您想更新什么以及何时更新?一点也不清楚

      首先,我真的很抱歉忘记在应用程序UI中fluidRow之后添加以下CSS行<代码>inlineCSS(“.row{margin:60px 0;}div[id*='input\u div']{位置:绝对;左:6em;宽度:200px;高度:30px;}div[id*='input2\u div']{位置:绝对;左:20em;宽度:200px;高度:30px;div[id*='Def\u id']{位置:绝对;左:30em;宽度:200px;高度:30px;”),
如果没有这些行,输入面板将无法正常显示。第一点:我的模块服务器正在工作,因为如果我从应用程序服务器传递一个表,它会将该表显示为模块服务器的DatatTableOutput。@第二点:我不理解您在模块服务器中的命名空间引用。我必须由于在模块ui中定义了uioutput,请在模块服务器中使用输入命名空间。@LimeyThird Point:我希望在打开应用程序后,立即显示模块服务器中“观察”部分中给出的值,而不是模块服务器中“渲染”部分中的原始值。首先,我非常抱歉忘记使用inc在应用程序UI中,在fluidRow之后删除以下CSS行。
inlineCSS(.row{margin:60px 0;}div[id*='input_div']{position:absolute;left:6em;width:200px;height:30px;}div[id*='input2_div']{position:absolute;left:20em;width:200px;height:30px;div[id*='Def_id*='id']{位置:绝对;左侧:30em;宽度:200px;高度:30px;“”),
如果没有这些行,输入面板将无法正常显示。第一点:我的模块服务器正在工作,因为如果我从应用程序服务器传递一个表,它会将该表显示为模块服务器的DatatTableOutput。@第二点:我不理解您在模块服务器中的命名空间引用。我必须由于在模块ui中定义了uioutput,因此在模块服务器中禁用输入命名空间。@LimeyThird Point:我希望在打开应用程序后,立即显示模块服务器中“观察”部分中给定的值,而不是模块服务器中“渲染”部分中的原始值。
 #Module UI

 ui_module <- function(id){
   ns <- NS(id)

   fluidRow(
          uiOutput(ns("Input_ui"))
         )
    }
#Module Server

server_module <- function(input,output,session){
 ns <- session$ns

 output$Input_ui <- renderUI({
      list(
    tags$div(id = ns("input_div"),numericInput(ns("Input"), "Number",NA,value = 537153, step = 1)),
    tags$div(id = ns("input2_div"),numericInput(ns("Input2"),"Number2",NA,value = 686575, step =1))
  )
})

 observe({
     updateNumericInput(session,
                   "Input", "Number",value = 4, step = 1)    
     updateNumericInput(session,
                   "Input2", "Number2",value = 8.9, step = 1)
     })  
}

#APP UI

ui <- fluidPage(
    fluidRow(id = "Row",
          ui_module("panels")  
     )
  )

#APP Server

server <- function(input,output,session){
    callModule(server_module,"panels")
 }
 shinyApp(ui,server)