【问题标题】:Possible incompatibilty "div" tags and updateSelectInput可能不兼容的“div”标签和 updateSelectInput
【发布时间】:2020-04-27 07:44:58
【问题描述】:

我正在使用 Shiny Flexdashboard,但我遇到了 updateSelectInput 和 CSS 代码的问题... 我想要解决问题的替代方案...

我想减小表格大小,但我是 html、CSS 和相关内容的新手,所以我从 herehere(以及在 flexdashboard 中特别提到的here)中找到了灵感,并编写了代码类似于以下内容:


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)

它使我想要的数据表中的行更小,但是问题是,selectInput“Indicator”没有更新。

什么有效:如果我评论/排除该行,则 selectInput“指标”已充分更新

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

所以,我无法让它们同时工作......

即使我将选择输入放在侧边栏并将数据表放在另一个选项卡中,也会发生同样的情况......

CSS 的“div”代码和 updateSelectInput 之间存在某种不兼容?在不阻止 updateSelectInput 的情况下,如何使用 flexdashboard 中的样式(特别是 dataTableOutput 字体大小)?

【问题讨论】:

    标签: css r shiny flexdashboard


    【解决方案1】:

    这更像是一种解决方法,而不是完全的解决方案。但我认为包含我如何解决它是一个好主意......它与the answer indicated here相关并使用DT(如here所述) 这不是我最初的意图,行名、标题行保持原始大小,而是一种解决部分问题的方法。

        ```{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%')
      )
    
    ```
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-09-27
      • 1970-01-01
      • 2021-05-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-19
      相关资源
      最近更新 更多