Skip to content

data_bars() column not updating when new data is set with reactable JS API  #58

@tilltnet

Description

@tilltnet

Hi,

When I use Reactable.setData() to update the content of a table via Javascript, columns that use data_bar() are not updated.

This is a short quarto example that demonstrates the issue. In the rendered document, when you click the button, it will update the "word" column of the table, while the "number" column doesn't change.

---
title: "Test data_bars()"
format: html
editor: source
---

```{r}
library(tidyverse)
library(reactable)
library(reactablefmtr)
```

```{r}
df1 <-
  tibble(
    word = rep("one", 15),
    number = rep(1, 15)
  )

df2 <-
  tibble(
    word = rep("two", 15),
    number = rep(2, 15)
  )

ojs_define(data_json = jsonlite::toJSON(df2))
```

```{r}
reactable(df1,
          columns =
            list(number = colDef(cell = data_bars(df1))),
          elementId = "test_tbl")
```

```{ojs}
viewof clicks = Inputs.button("Click me")
data = JSON.parse(data_json)

{if(clicks > 0) Reactable.setData("test_tbl", data)}
```

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions