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

标签 r datatables shiny flexdashboard

我正在编写一个 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)
```

我现在正在尝试使用由 shiny with 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))  
)
```

关于如何正确填充容器的任何想法? 非常感谢

最佳答案

设置fillContainer = FALSE

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

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

关于r - 使用 Flexdashboard 在 Shiny tabpanel 中用 DataTable 填充容器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44019465/

相关文章:

r - ggplot2 geom_密度限制

javascript - 悬停散点图时显示变量名称

javascript - Backbone JS 数据表集成

R Shiny 改变情节高度

r - SelectInput Value update based on previous SelectInput in R shiny

r - R 中的并行包在 Windows 上通过引用传递大对象

r - 取消列出并拆分列以添加到行而不会丢失 R 中其他列的信息

javascript - DataTables 需要哪些文件才能在 html 页面上工作>

java - JQuery 数据表隐藏列

r - 更改 valueBoxes 的字体大小