我正在尝试构建一个闪亮的小工具,以使用DT库浏览数据表中的数据。我希望DT小部件填充整个闪亮的页面或屏幕,但是表格的固定高度较低。如何获取表格以填充UI?
我已经将dataTableOutput的高度参数设置为100%,并且尝试了不同的UI容器(例如,sillPage)而不是miniUI,但没有成功。
这是我的代码的精简版:
library(shiny)
library(miniUI)
library(DT)
ViewDT <- function(data) {
ui <- miniPage(
DT::dataTableOutput("mytable1", height = "100%")
)
server <- function(input, output, session) {
output$mytable1 <- DT::renderDataTable({
table <- DT::datatable(data,
extensions = c('Buttons','Scroller'),
options = list(dom = 'BrtS',
buttons = I('colvis'),
scrollY = 200,
deferRender = TRUE,
paging = T
)
)
})
}
runGadget(ui, server, viewer = dialogViewer("Data"))
}
ViewDT(iris)
结果:The table fills about half of the dialog viewer instead of its entirety.
答案 0 :(得分:0)
您可以使用:fillContainer = TRUE
:
library(shiny)
library(miniUI)
library(DT)
ViewDT <- function(data) {
ui <- miniPage(
DT::dataTableOutput("mytable1", height = "100%")
)
server <- function(input, output, session) {
output$mytable1 <- DT::renderDataTable({
table <- DT::datatable(data,
extensions = c('Buttons','Scroller'),
options = list(dom = 'BrtS',
buttons = I('colvis'),
scrollY = 200,
deferRender = TRUE,
paging = TRUE
),
fillContainer = TRUE
)
})
}
runGadget(ui, server, viewer = dialogViewer("Data"))
}
ViewDT(iris)