Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
tilltnet opened this issue Jul 20, 2023 · 0 comments

Comments

@tilltnet
Copy link

tilltnet commented Jul 20, 2023

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)}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant