【问题标题】:fluidRow in shinydashboard sidebar swaps into body or is split into two rowsshinydashboard 侧边栏中的fluidRow 交换为正文或分成两行
【发布时间】:2018-04-25 07:20:54
【问题描述】:

我正在尝试将fluidRow 合并到闪亮仪表板应用程序的侧边栏中。我希望通过这样做,我可以将侧边栏的宽度分成 12 列。然而,发生的情况是侧边栏中仅显示 10 或 11 列,而其余列交换到仪表板正文或移动到下面的行。比如代码

library(shiny)
library(shinydashboard)

ui <- dashboardPage(
  dashboardHeader(title = "Dynamic sidebar"),
  dashboardSidebar(
    sidebarMenuOutput("menu")
  ),
  dashboardBody()
)

server <- function(input, output) {
  output$menu <- renderMenu({
    sidebarMenu(
      fluidRow(
        column(10, textInput("TextInput", "Text")),
        column(2, checkboxInput("CheckBox", "Check?"))
     )
    )
  })
}

shinyApp(ui, server)

生成布局(分辨率为 1680 x 1050)

使用 11-1 拆分复选框移动到下面的行

In 如何确保侧边栏中的fluidRow 将始终保持在侧边栏内且恰好在一行中?

【问题讨论】:

    标签: shiny shinydashboard


    【解决方案1】:

    这样可以吗?

    library(shiny)
    library(shinydashboard)
    
    ui <- dashboardPage(
      dashboardHeader(title = "Dynamic sidebar"),
      dashboardSidebar(
        sidebarMenuOutput("menu")
      ),
      dashboardBody()
    )
    
    server <- function(input, output) {
      output$menu <- renderMenu({
        sidebarMenu(
          fluidRow(
          div(style="display: inline-block; width: 62%;",textInput("TextInput", "Text")),
          div(style="display: inline-block; width: 4%;",checkboxInput("CheckBox", "Check?")))
        )
      })
    }
    
    shinyApp(ui, server)
    

    【讨论】:

    • 并非如此,因为如果您在流体行之前插入textInput("TextInput1", "Text1"),,则两个textInput 框会出现错位。基本上我正在寻找一种可以批量工作的解决方案,并且不需要针对每种情况进行检查和重新调整。
    猜你喜欢
    • 2021-08-09
    • 2021-09-28
    • 1970-01-01
    • 2016-05-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-03
    • 1970-01-01
    相关资源
    最近更新 更多