我无法使用该函数控制我添加到闪亮应用程序的数据表的宽度dataTableOutput().我试图width在函数中使用参数,但它在输出中没有任何改变,并且没有错误〜它没有告诉我它忽略了width参数.
library(shiny)
library(shinythemes)
ui <- fluidPage(theme = shinytheme("Spacelab"),
fluidRow(
column(6,dataTableOutput(outputId = "table")),
column(6,p(textOutput("para")))
)
)
server <- function(input, output){
df <- as.data.frame(matrix(0, ncol = 15, nrow = 20))
output$table <- renderDataTable({df})
output$para <- renderText({
text <- rep(x = "Hello World",1000)
})
}
shinyApp(ui = ui,server = server)
Run Code Online (Sandbox Code Playgroud)
CSJ*_*ell 24
dataTableOutput没有参数宽度.您可以column在fluidRowwith参数宽度内使用,提供1到12之间的整数.
library(shinythemes)
ui <- fluidPage(theme = shinytheme("Spacelab"),
fluidRow(
column(
dataTableOutput(outputId = "table"), width = 6)
)
)
server <- function(input, output){
df <- as.data.frame(matrix(0, ncol = 20, nrow = 5))
output$table <- renderDataTable({df},
options = list(scrollX = TRUE))
}
shinyApp(ui = ui,server = server)
Run Code Online (Sandbox Code Playgroud)
JavaScript库DataTable中的选项可以通过renderDataTable参数选项直接传递.例如,将scrollX设置为true允许表滚动.
小智 7
如果您使用"DT"R包和相应的DT::dataTableOutput和DT::renderDataTable,您可以使用"宽度"选项与这些调用,显然可以是%(例如宽度="100%")或像素(宽度= 300)哪个应该让你得到你想要的控制权.
请参阅:https: //rstudio.github.io/DT/shiny.html
从该页面注意:
重要:确保在调用dataTableOutput和renderDataTable时使用DT ::前缀,以便保证调用这些函数的DT版本,而不是被弃用的Shiny版本.如果确保库(光泽)之后的库(DT),通常DT版本应该覆盖闪亮版本,如果你不使用DT ::前缀(如果有疑问,请使用此前缀,直到我们完全删除这些函数来自闪亮)
| 归档时间: |
|
| 查看次数: |
24225 次 |
| 最近记录: |