rstudio / rstudio/flexdashboard

DT::renderDataTable Example Broken

Open
#101 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
848
Forks
298
PR merge metrics
No merged PRs in 30d

Description

Hello,

I had some code working on macOS which then broke when I switched to windows. I isolated it to DT::renderDataTable.

The exact example on the documentation website that's broken is here: (http://rmarkdown.rstudio.com/flexdashboard/using.html), specifically this snippet:

### Cars

```{r}
DT::renderDataTable({
  data <- head(mtcars, n = input$maxrows)
  DT::datatable(data, options = list(
    bPaginate = FALSE
  ))
})

Here is a reproducible minimal example showing DT::renderDataTable not working where
shiny::renderDataTable and shiny::renderTable both still work.

---
title: "Bug Report"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
runtime: shiny
---

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

Column {.sidebar}
---------------------------------------------------------------------
```{r}
shiny::sliderInput("maxrows", "max rows", 1, 40, 10, 1)
```


Column 
-----------------------------------------------------------------------
```{r}
mtcars2 <- reactive({head(mtcars, n = input$maxrows)})
```

```{r}
DT::renderDataTable({
  DT::datatable(mtcars2(), options = list(
    bPaginate = FALSE
  ))
})
```

Column 
-----------------------------------------------------------------------

```{r}
shiny::renderDataTable({mtcars2()})
```

```{r}
shiny::renderTable({mtcars2()})
```

After running this document, the reactive elements are not drawn.
image

However, if I create at DT::datatable outside a reactive context first, then all the datatable created in the reactive context draws.
So adding in this chunk

### Not-reactive DT::Datatable
```{r}
DT::datatable(mtcars, options = list(
  pageLength = 25
))
```

yeilds this

image

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the supplied minimal flexdashboard document and compare DT::renderDataTable with the working shiny renderers, including the non-reactive DT::datatable case. Done means the reactive DT table renders correctly on Windows and the documentation example at using.html works as shown.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
frontend, web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.