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

Unexpected interaction between columnGroups and groupBy #87

Closed
tdeenes opened this issue Oct 10, 2020 · 4 comments
Closed

Unexpected interaction between columnGroups and groupBy #87

tdeenes opened this issue Oct 10, 2020 · 4 comments

Comments

@tdeenes
Copy link

tdeenes commented Oct 10, 2020

If both columnGroups and groupBy arguments are provided, the groupBy column receives the default column header (see defaultGroupHeader in reactableLang()).

reactable(
  iris[1:5, ],
  columns = list(
    Sepal.Length = colDef(name = "Length"),
    Sepal.Width = colDef(name = "Width"),
    Petal.Length = colDef(name = "Length"),
    Petal.Width = colDef(name = "Width")
  ),
  columnGroups = list(
    colGroup(name = "Sepal", columns = c("Sepal.Length", "Sepal.Width")),
    colGroup(name = "Petal", columns = c("Petal.Length", "Petal.Width"))
  ),
  groupBy = "Species"
)

Is this intentional?

@glin
Copy link
Owner

glin commented Oct 10, 2020

Yes, this is intentional, and inherited from the underlying React Table library. However, it'll be removed in the next release, along with the defaultGroupHeader argument.

For now, there's no way to get rid of that default column group, but you can give it an empty name. To make it look less awkward, you could also use a bordered style:

reactable(
  iris[1:5, ],
  columns = list(
    Sepal.Length = colDef(name = "Length"),
    Sepal.Width = colDef(name = "Width"),
    Petal.Length = colDef(name = "Length"),
    Petal.Width = colDef(name = "Width")
  ),
  columnGroups = list(
    colGroup(name = "", columns = "Species"),
    colGroup(name = "Sepal", columns = c("Sepal.Length", "Sepal.Width")),
    colGroup(name = "Petal", columns = c("Petal.Length", "Petal.Width"))
  ),
  groupBy = "Species",
  bordered = TRUE
)

reactable output

In the next release, there won't be a column group unless you specifically create one:

grouped reactable with column groups

@tdeenes
Copy link
Author

tdeenes commented Oct 11, 2020

@glin , thanks for the quick response (and for the package as well :). What is the ETA of the next release?

@glin
Copy link
Owner

glin commented Oct 12, 2020

I don't have an ETA yet, and those changes aren't even up on GitHub. But I'll comment here again once it's available in the development version.

@glin
Copy link
Owner

glin commented Jan 10, 2021

The automatic column grouping is now removed in the development version (d9ac371). Since it could be a breaking change in some cases, I've marked it so in the NEWS:

Breaking changes

  • When both columnGroups and groupBy arguments are provided, groupBy columns are no longer added to a column group automatically (#87).
  • The defaultGroupHeader argument in reactableLang() is now deprecated and no longer used. Use the columnGroups argument in reactable() to customize the column group header for groupBy columns.

@glin glin closed this as completed Jan 10, 2021
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

2 participants