Shinydashboard :: box中的splitLayout

时间:2018-07-24 12:56:37

标签: r shiny shinydashboard

目标

我想在actionButton的页脚中的selectInput旁边放置shinydashboard::box。根据{{​​3}},splitLayout应该做我想做的事。

问题

selectInput放在页脚中时不会填充整个空间。看来selectInput在页脚中始终采用固定宽度。有趣的是,将相同的元素放入框的主体时,控件将按预见的方式呈现。

问题

我如何管理selectInputactionButton

  1. 彼此相邻并且
  2. 全线吗?

代码

library(shiny)
library(shinydashboard)

boxUI <- function(width) {
  box(
    splitLayout(
      selectInput("x", NULL, paste(strrep("x", 10), 1:10)),
      actionButton("ok", icon("trash")),
      cellWidths = c("85%", "15%"),
      cellArgs = list(style = "vertical-align: top")),
    footer = splitLayout(
      selectInput("y", NULL, paste(strrep("x", 10), 1:10)),
      actionButton("ok", icon("trash")),
      cellWidths = c("85%", "15%"),
      cellArgs = list(style = "vertical-align: top")
    ), width = width, solidHeader = TRUE, status = "info", title = "Box")
}

ui <- dashboardPage(
  dashboardHeader(), 
  dashboardSidebar(),
  dashboardBody(
    tags$head(
      tags$style(
        HTML(".shiny-split-layout > div {
                  overflow: visible;
              }"))),
    fluidRow(
      boxUI(4),
      boxUI(3))
  ))

server <- function(input, output) {
}

shinyApp(ui, server)

this SO question

1 个答案:

答案 0 :(得分:1)

如果将selectInput放在div内并将宽度设置为100%,那么应该可以找到所需的内容。

footer = splitLayout(
    tags$div(
        selectInput("y", NULL, paste(strrep("x", 10), 1:10), width="100%")
    ),
    actionButton("ok", icon("trash")),
    cellWidths = c("85%", "15%"),
    cellArgs = list(style = "vertical-align: top")
),

selectInput uses correct width