代码之家  ›  专栏  ›  技术社区  ›  thothal

ShinyDashboard中的拆分布局::Box

  •  0
  • thothal  · 技术社区  · 6 年前

    目标

    我想在a shinydashboard::box的页脚中的a selectinput actionbutton 旁边放置一个。根据 this so question splitlayout should do what I want.

    问题

    当放入页脚时, selectinput 不会填满整个空格。似乎在页脚中, selectinput always takes a fixed width.有趣的是,当将相同的元素放入盒体时,控件将呈现为可预见的。

    问题

    如何管理 selectinput actionbutton

    1. 彼此紧挨着
    2. 跨越整条线?

    代码

    library(闪亮)
    图书馆(Shinydashboard)
    
    boxui<-功能(宽度){
    箱(箱)
    分裂布局
    选择输入(“x”,空,粘贴(strrep(“x”,10),1:10)),
    actionButton(“确定”,icon(“垃圾桶”)),
    细胞宽度=c(“85%,”15%“),
    Cellargs=List(style=“Vertical Align:Top”),
    footer=拆分布局(
    选择输入(“Y”,空,粘贴(strrep(“X”,10),1:10)),
    actionButton(“确定”,icon(“垃圾桶”)),
    细胞宽度=c(“85%,”15%“),
    酒窖=列表(style=“Vertical Align:Top”)
    ,width=width,solidHeader=true,status=“info”,title=“box”)。
    }
    
    ui<-仪表板页(
    仪表板标题(),
    仪表板边栏(),
    仪表板体
    标签头
    标签$风格
    HTML(“.shining split layout>div){
    溢出:可见;
    }))
    流水沟
    (4),
    博学(3)
    )
    
    服务器功能(输入、输出){
    }
    
    Shinyapp(用户界面,服务器)
    < /代码> 
    
    

    .。根据this SO questionsplitLayout应该做我想做的。

    问题

    这个选择输入放入页脚时,不填充整个空格。似乎一旦在页脚选择输入始终采用固定宽度。有趣的是,当将相同的元素放入盒体时,控件将呈现为可预见的效果。

    问题

    我该怎么办选择输入以及动作按钮

    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)
    

    enter image description here

    1 回复  |  直到 6 年前
        1
  •  1
  •   Grant MKK    6 年前

    如果将 selectinput inside a div and set the width to 100%,that should give you're looking for.

    footer=splitlayout(
    标签$DIV(
    选择输入(“Y”,空,粘贴(strrep(“X”,10),1:10),width=“100%”)
    )
    actionButton(“确定”,icon(“垃圾桶”)),
    细胞宽度=c(“85%,”15%“),
    酒窖=列表(style=“Vertical Align:Top”)
    )
    < /代码> 
    
    

    selectInput uses correct width