简体   繁体   English

使用 Flexdashboard 在 Shiny tabpanel 中用 DataTable 填充容器

[英]Fill container with DataTable in Shiny tabpanel using Flexdashboard

I am writing a flexdashboard that shows dataframes with DataTable (DT) in tabs.我正在编写一个 flexdashboard,它在选项卡中显示带有 DataTable (DT) 的数据框。

When using fillContainer=T on DT and normal flexdashboard tabs, I get the desired result: my datatables fill their whole container but not more.在 DT 和普通 flexdashboard 选项卡上使用fillContainer=T时,我得到了想要的结果:我的数据表填满了它们的整个容器,但不会更多。

Shinyapps.io : Flexdashboard Tabs with DT's fillContainer=T Shinyapps.io:带有 DT 的 fillContainer=T 的 Flexdashboard 选项卡

Flexdashboard Tabs with DT::FillContainer
======================

Column {.tabset .tabset-fade}
-----------------------------------------------------------------------

### iris 

```{r}
DT::datatable(
    iris,
    fillContainer = T,
    rownames = F)
```

### mtcars 

```{r}
DT::datatable(
    mtcars,
    fillContainer = T,
    rownames = F)
```

I am now trying to use tabs generated dynamically by shiny with tabsetPanel instead of flexdashboard tabs.我现在尝试使用由带有tabsetPanel而不是 flexdashboard 选项卡的闪亮动态生成的选项卡。 I tried both with and without fillContainer=T .我尝试了使用和不使用fillContainer=T But the datatables don't fill the container exactly and are either too long in height or very short (less than 2 rows).但是数据表并没有完全填充容器,并且高度太长或太短(少于 2 行)。 In both cases the pagination options show below the last row and not at the bottom of the container.在这两种情况下,分页选项都显示在最后一行的下方而不是容器的底部。

Shinyapps.io : Shiny Tabs with DT's fillContainer=T Shinyapps.io:带有 DT 的 fillContainer=T 的闪亮标签

Shiny Tabs with DT::fillContainer 
======================

Column {.tabset .tabset-fade}
-----------------------------------------------------------------------

### Tabs container with fillContainer

```{r}
library(shiny)
tabsetPanel(
  tabPanel("iris",
    DT::datatable(
      iris,
      fillContainer = T,
      rownames = F)),
  tabPanel("mtcars",
    DT::datatable(
      mtcars,
      fillContainer = T,
      rownames = F))  
)
```

Shinyapps.io : Shiny Tabs without DT's fillContainer=T Shinyapps.io:没有 DT 的 fillContainer=T 的闪亮标签

Shiny Tabs without DT::fillContainer 
======================

Column {.tabset .tabset-fade}
-----------------------------------------------------------------------

### Tabs container without fillContainer

```{r}
library(shiny)
tabsetPanel(
  tabPanel("iris",
    DT::datatable(
      iris,
      fillContainer = F,
      rownames = F)),
  tabPanel("mtcars",
    DT::datatable(
      mtcars,
      fillContainer = F,
      rownames = F))  
)
```

Any idea on how to get proper filling of containers?关于如何正确填充容器的任何想法? Thanks a lot非常感谢

Set fillContainer = FALSE设置fillContainer = FALSE

Add style = "height:550px; overflow-y: scroll;"添加style = "height:550px; overflow-y: scroll;" as an argument to tabPanel.作为 tabPanel 的参数。

I used this successfully in shinydashboard where tabPanels are part of the tabBox argument.我在闪亮的仪表板中成功地使用了它,其中 tabPanels 是 tabBox 参数的一部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM