Search code examples
cssrshinyflexdashboard

Possible incompatibilty "div" tags and updateSelectInput


I am working in a Shiny Flexdashboard and I having a issue with updateSelectInput, and CSS code... I would like alternatives to solve the issue...

I wanted to lower a table size but I am new in html, CSS and related stuff, so I found the inspiration from here and here (and here specifically mentioned as implemented in flexdashboard) and coded the similar to the following:


selectInput("Indicator","select",choices=c(),selected="NONE")
observe({

  Inds<-as.factor(mtcars[,2])%>%levels

  updateSelectInput(session,inputId="Indicator",choices=Inds)

})


  wellPanel(
    div (dataTableOutput ("OrigData"), style = "font-size: 80%"),
    dataTableOutput("OrigData"),
  )


output$OrigData<-DT::renderDataTable(mtcars)

It makes the lines smaller in the data table rendered as I want, but, the problem is, the selectInput "Indicator" is not updated.

What works: The selectInput "Indicator" is adequately updated if I comment/exclude the line

div (dataTableOutput ("OrigData"), style = "font-size: 80%")

So, I am unable to make they work simultaneously...

The same happens even if I put the select input on the sidebar and the data table in another tab...

There is a kind of incompatibility between the CSS's "div" code and updateSelectInput? What can I do to work with style in flexdashboard (specifically dataTableOutput font-size) without blocking the updateSelectInput?


Solution

  • This is more a workaround, not exactly a solution. But I think it was a good idea to include how I worked around it... It's related to the answer indicated here and uses DT (as described here) That's not exactly my initial intent, the rownames, title row remain with the original size, but a way to approach partially the issue.

        ```{r,echo=FALSE}
    
    selectInput("Indicator","select",choices=c(),selected="NONE")
    observe({
    
      Inds<-as.factor(mtcars[,2])%>%levels
    
      updateSelectInput(session,inputId="Indicator",choices=Inds)
    
    })
    
    
      wellPanel(
        #div (dataTableOutput ("OrigData"), style = "font-size: 80%"),
        dataTableOutput("OrigData"),
      )
    
    
    output$OrigData<-DT::renderDataTable(mtcars%>%
      DT::datatable() %>%
      DT::formatStyle(columns = colnames(mtcars), fontSize = '50%')
      )
    
    ```