首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >在闪亮的应用程序中将小部件设置在同一行中

在闪亮的应用程序中将小部件设置在同一行中
EN

Stack Overflow用户
提问于 2018-06-29 02:48:50
回答 1查看 907关注 0票数 2

我有一个闪亮的应用程序,它产生了一个良好的面板与一些小工具。

代码语言:javascript
复制
    #ui.r
navbarPage(
  "Application",
  tabPanel("General",
           sidebarLayout(
             
             sidebarPanel(
               
             ),
             
             mainPanel(
               wellPanel(
                 h4("Format"),
                 fluidRow( # Width = sum of component columns 
                   tags$style(type="text/css",
                              ".shiny-output-error { visibility: hidden; }",
                              ".shiny-output-error:before { visibility: hidden; }"
                   ),
                   column(3,
                          h5("Booklet ID"),
                          div(style="display: inline-block;vertical-align:top; width: 150px;",uiOutput("num3"))
                          
                          
                   ),
                   column(
                     3,h5("Data"),
                     div(style="display: inline-block;vertical-align:top; width: 150px;",uiOutput("num4"))
                     
                     
                   ),
                   column(3,
                          uiOutput("c1"),
                          div(style="display: inline-block;vertical-align:top; width: 150px;",uiOutput("num8")),
                          uiOutput("help1")),
                   
                   column(
                     3,
                     uiOutput("c2"),
                     div(style="display: inline-block;vertical-align:top; width: 150px;",uiOutput("num10")),
                     uiOutput("help3")
                     
                     
                   )
                 ),
                 column(width = 12, fixedRow( # Width = sum of component columns fluidRow
                   tags$style(type="text/css",
                              ".shiny-output-error { visibility: hidden; }",
                              ".shiny-output-error:before { visibility: hidden; }"
                   ),
                   column(
                     3,
                     div(style="display: inline-block;vertical-align:top; width: 150px;",uiOutput("num5"))
                     
                     
                   ),
                   column(
                     3,
                     div(style="display: inline-block;vertical-align:top; width: 150px;",uiOutput("num7"))
                     
                     
                   ),
                   column(
                     3,
                     div(style="display: inline-block;vertical-align:top; width: 150px;",uiOutput("num9")),
                     uiOutput("help2")
                     
                     
                   ),
                   column(
                     3,
                     div(style="display: inline-block;vertical-align:top; width: 150px;",uiOutput("num11")),
                     uiOutput("help4")
                     
                     
                   )
                 )))
               
               
               
             )
           )
           
  )
)
#server.r
library(shiny)

server <- function(input, output,session) {

  output$num3<-renderUI({
    textInput("nm3", 
              h6("Column"), 
              value = 1)
  })
  output$num4<-renderUI({
    textInput("nm4", 
              h6("First Column"), 
              value = as.numeric(input$nm3)+input$nm5)
  })
  
  output$num5<-renderUI({
    numericInput("nm5", 
                 h6("Length"), 
                 value = 2)
  })
  
  output$num7<-renderUI({
    numericInput("nm7", 
                 h6("Length Response"), 
                 value = 1)
  })
  
  output$c1<-renderUI({
    checkboxInput("ch1", 
                  h5("Person ID"), value = FALSE)
  })
  
  output$num8<-renderUI({
    if(input$ch1==T){
      textInput("nm8", 
                h6("Column"), 
                value = 1)
    }
    else{
      output$help1<-renderUI({
        helpText("Click Person ID")
      }) 
    }
    
  })
  output$num9<-renderUI({
    if(input$ch1==T){
      numericInput("nm9", 
                   h6("Length"), 
                   value = 1)
    }
    else{
      output$help2<-renderUI({
        helpText("Click Person ID")
      }) 
    }
  })
  
  output$c2<-renderUI({
    checkboxInput("ch2", 
                  h5("Covariates"), value = FALSE)
  }) 
  
  
  output$num10<-renderUI({
    if(input$ch2==T){
      textInput("nm10", 
                h6("Column"), 
                value = 1)
    }
    else{
      output$help3<-renderUI({
        helpText("Click Covariates")
      }) 
    }
  })
  output$num11<-renderUI({
    if(input$ch2==T){
      numericInput("nm11", 
                   h6("Length"), 
                   value = 1)
    }
    else{
      output$help4<-renderUI({
        helpText("Click Covariates")
      }) 
    }
  })
  

}

我想在我的well面板中实现所有的东西都在同一行。问题是,正如你将在下面看到的,我可以部分地实现这一点。

我在第三行就做到了

但我不能在第二种情况下应用它

我使用的是div(style="display: inline-block;vertical-align:top; width: 150px;",但它看起来是局部工作的。

EN

回答 1

Stack Overflow用户

发布于 2018-06-29 02:55:32

更新:这不适用于,并以某种方式迫使第三行退出良好面板。这可能是由于CSS、if_else renderUI之类的东西造成的。不幸的是,我现在不能贬低自己...

您只需要将列包装在fixedRow()中。

对于您的第二行,请尝试:

代码语言:javascript
复制
    column(width = 12, fixedRow( # Width = sum of component columns 
    column(
                 3,
                 div(style="display: inline-block;vertical-align:top; width: 150px;",uiOutput("num5"))


               ),
               column(
                 3,
                 div(style="display: inline-block;vertical-align:top; width: 150px;",uiOutput("num7"))


               ),
               column(
                 3,
                 div(style="display: inline-block;vertical-align:top; width: 150px;",uiOutput("num9")),
                 uiOutput("help2")


               ),
               column(
                 3,
                 div(style="display: inline-block;vertical-align:top; width: 150px;",uiOutput("num11")),
                 uiOutput("help4")
    )) # One ) for the column, one more for the fixed row. End the fluid row appropriately
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51089530

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档