我有一个相当复杂的闪亮代码,内部包含多个面板和多个表格。当应用程序启动时,列名与列值正确对齐。但是一旦我在应用程序中的表格下更改页数,列名就会向左移而值仍然在中心位置。我该如何强制应用程序使列名与列值保持对齐?
可重现的示例:
library(shiny)
library(dplyr)
library(DT)
library(dplyr)
ui <- fluidPage(
titlePanel("Test Example"),
fluidRow(
column(3, align="left",
# Input: Quantile ----
selectInput(inputId = "Variable",
label = "Variable :",
choices = c(80, 85, 90, 95),
selected = 90)),
column(9,
tabsetPanel(
tabPanel("Table d'évènements", verticalLayout(p(dataTableOutput("cars.table")),
p(dataTableOutput("cars.table2"))))))
)
)
server <- function(input, output) {
output$cars.table <- DT::renderDataTable({
df <- summarise(group_by(cars, speed), n=mean(dist))
df
}, options=list(autoWidth = TRUE, scrollX=T, pageLength=5), rownames= FALSE)
output$cars.table2 <- DT::renderDataTable({
df1 <- summarise(group_by(cars, speed), n=max(dist))
df1
}, options = list(autoWidth = TRUE,scrollX=T,pageLength=10),rownames= FALSE)
}
shinyApp(ui = ui, server = server)
我找到了以下这些主题:
还有
但是它们并没有提供解决方案,我需要使用autowidth = T,并且设置列宽度不会改变错位问题。
谢谢。