I have a fluidPage
with a sidebarLayout
. In the mainPanel
, I have a very wide dataTableOutput
(in a tabPanel
).
我有一个带有sidebarLayout的fluidPage。在mainPanel中,我有一个非常宽的dataTableOutput(在tabPanel中)。
Currently, the columns are being squished together and each row is text-wrapped to span many lines. However, I want each row of the table not to be text-wrapped and to enable horizontal scrolling on the page.
目前,列被挤压在一起,每行都是文本包装的,以跨越许多行。但是,我希望表的每一行都不是文本包装的,并且要在页面上启用水平滚动。
Minimal working example:
最小的工作示例:
library(shiny)
nrow <- 20; ncol <- 26
runApp(list(
ui = fluidPage(
sidebarLayout(
sidebarPanel(helpText("Hello world")),
mainPanel(
tabsetPanel(
tabPanel("Table", dataTableOutput("table"))
)
)
)
),
server = function(input, output, session) {
output$table <- renderDataTable(
as.data.frame(
matrix(nrow = nrow,
rep("The quick brown fox jumps over the lazy dog", nrow*ncol)
)
)
)
}
))
...which outputs:
...输出:
Now, how to prevent "The quick brown fox jumps over the lazy dog" from being text-wrapped and so occupy just a single line?
现在,如何防止“快速的棕色狐狸跳过懒狗”被文字包裹,因此只占一条线?
Is there some option I can set to make the page wider?
我可以设置一些选项以使页面更宽广吗?
1 个解决方案
#1
1
Surrond your tabpanel with a div giving a width. Add some css to change the max-width of a fluid container
使用带宽度的div来展示你的tabpanel。添加一些css来更改流体容器的最大宽度
library(shiny)
nrow <- 20; ncol <- 26
runApp(list(
ui = fluidPage(
sidebarLayout(
sidebarPanel(helpText("Hello world")),
mainPanel(
tabsetPanel(
div(tabPanel("Table", dataTableOutput("table")), style = 'width:5500px;')
)
,
tags$head(tags$style(type="text/css", ".container-fluid { max-width: 12600px; /* or 950px */}"))
)
)
),
server = function(input, output, session) {
output$table <- renderDataTable({
as.data.frame(
matrix(nrow = nrow,
rep("The quick brown fox jumps over the lazy dog", nrow*ncol)
)
)
})
}
))
#1
1
Surrond your tabpanel with a div giving a width. Add some css to change the max-width of a fluid container
使用带宽度的div来展示你的tabpanel。添加一些css来更改流体容器的最大宽度
library(shiny)
nrow <- 20; ncol <- 26
runApp(list(
ui = fluidPage(
sidebarLayout(
sidebarPanel(helpText("Hello world")),
mainPanel(
tabsetPanel(
div(tabPanel("Table", dataTableOutput("table")), style = 'width:5500px;')
)
,
tags$head(tags$style(type="text/css", ".container-fluid { max-width: 12600px; /* or 950px */}"))
)
)
),
server = function(input, output, session) {
output$table <- renderDataTable({
as.data.frame(
matrix(nrow = nrow,
rep("The quick brown fox jumps over the lazy dog", nrow*ncol)
)
)
})
}
))