简体   繁体   中英

Fill container with DataTable in Shiny tabpanel using Flexdashboard

I am writing a flexdashboard that shows dataframes with DataTable (DT) in tabs.

When using fillContainer=T on DT and normal flexdashboard tabs, I get the desired result: my datatables fill their whole container but not more.

Shinyapps.io : Flexdashboard Tabs with DT's fillContainer=T

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. I tried both with and without 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). 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

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

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

Add style = "height:550px; overflow-y: scroll;" as an argument to tabPanel.

I used this successfully in shinydashboard where tabPanels are part of the tabBox argument.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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