1

Hello I have a shiny app that should read a list of configurations from a database and prompt the user with the list of configurations.

The list depends on some GET parameters, according to them the list can be different.

I tried two approaches:

  1. in ui.R I put only one big uiOutput element and inside it's implementation (in server.R) I will do an lapply and foreach configuration I will output a fluidRow with some elements in it.

    ui.R:
    uiOutput("serversList")
    
    server.R:
    output$serversList <- renderUI({
        lapply( get.servers()$server, function(servName) {...
    
  2. in ui.R I put an lapply based on the list that comes from the database, and for each configuration I will output a fluidRow with new output objects. In server.R I put another lapply based on the same list that comes from the database, and for each configuration i will define the implementation of each output object dynamically defined in ui.R

    ui.R
    fluidRow(
       box(width=12, 
    
          lapply(get.servers()$server, function(serv) {...
          list(
              uiOutput(paste0('conf', serv)),...
    
    server.R
    lapply(get.servers()$server, function(servName) {
        output[[paste0('conf', servName)]] <- renderUI({...
    

solution 1 works, but every time that I change some configuration the whole list of configurations is refreshed, and the values set by the user were lost. I need a way to control what object should be updated when.

solution 2 doesn't work if I fetch data from a database (in server.R).

If instead I fetch the data from a plain text file in global.R, solution 2 works and I can control what object should be updated when, because each output object is refreshed when the input objects used inside it changes.

Is there any solution 3? Or 1/2 can be fixed?

ciropom
  • 152
  • 1
  • 6

1 Answers1

0

I found the solution. I can fix solution 1, and inside renderUI for serversList I can define other renderUIs, return a fluidRow with uiOutput connected with the renderUIs.

Long story made short: nest solution 2 inside solution 1.

ciropom
  • 152
  • 1
  • 6
  • Look also at http://stackoverflow.com/questions/31813601/using-renderdatatable-within-renderui-in-shiny – ciropom Nov 18 '16 at 10:47