【问题标题】:Fill container with DataTable in Shiny tabpanel using Flexdashboard使用 Flexdashboard 在 Shiny tabpanel 中用 DataTable 填充容器
【发布时间】:2017-10-16 14:21:19
【问题描述】:

我正在编写一个 flexdashboard,它在选项卡中显示带有 DataTable (DT) 的数据框。

在 DT 和普通 flexdashboard 选项卡上使用 fillContainer=T 时,我得到了想要的结果:我的数据表填满了整个容器,但没有更多。

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)
```

我现在尝试使用由闪亮动态生成的选项卡和tabsetPanel,而不是 flexdashboard 选项卡。我尝试了有和没有fillContainer=T。但是数据表并没有完全填充容器,并且高度太长或非常短(少于 2 行)。在这两种情况下,分页选项都显示在最后一行下方,而不是容器底部。

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))  
)
```

知道如何正确填充容器吗? 非常感谢

【问题讨论】:

  • 我的错,我以为是关于宽度(右侧对齐);)

标签: r datatables shiny flexdashboard


【解决方案1】:

设置fillContainer = FALSE

style = "height:550px; overflow-y: scroll;" 作为参数添加到tabPanel。

我在shinydashboard 中成功使用了它,其中tabPanels 是tabBox 参数的一部分。

【讨论】:

    猜你喜欢
    • 2020-07-12
    • 2021-04-26
    • 2021-01-27
    • 1970-01-01
    • 2015-08-11
    • 2019-03-07
    • 2019-05-12
    • 2014-10-12
    • 2014-08-22
    相关资源
    最近更新 更多