rdtflexdashboard

Why is the vertical scroll here not working?


I am trying to get a vertical scroll but this isn't working, can anybody explain why? I would also like to default to show 20 rows at once.


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

Solution

  • The scrollY parameter isn't a boolean. You need to specify the fixed height of your table as 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"))
    ```