R垂直滚动不起作用

时间:2016-09-29 16:30:09

标签: dt flexdashboard

我正在尝试获得垂直卷轴,但这不起作用,任何人都可以解释原因吗?我还想默认一次显示20行。

谢谢

title: "Untitled"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
---

```{r setup, include=FALSE}
library(flexdashboard)
library(DT)
```

Column {data-width=650}
-----------------------------------------------------------------------

### Chart A

```{r}
datatable(cars ,options = list(c(bPaginate = F, scrollY=T)),  filter = 'top')
```

1 个答案:

答案 0 :(得分:11)

scrollY参数不是布尔值。您需要将表格的固定高度指定为per the datatables documentation

---
title: "Untitled"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
---

```{r setup, include=FALSE}
library(flexdashboard)
library(DT)
```

Column {data-width=650}
-----------------------------------------------------------------------

### Chart A

```{r}
DT::datatable(cars, filter = "top",
                    options = list(pageLength = 20, scrollY = "200px"))
```