reactable icon indicating copy to clipboard operation
reactable copied to clipboard

How to add multiple headers to the table?

Open Ivy-ops opened this issue 5 years ago • 2 comments

May I know how to add multiple headers to the table, similar as below, with reactable package? I see below code can draw 2 headers, but have difficulty in 3 headers (below figure show).

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"))
  )
)

Thanks!! image

Ivy-ops avatar Mar 11 '21 03:03 Ivy-ops

Hi, reactable doesn't support more than two levels of column headers, but I'll take this as a feature request.

In general though, I'd recommend breaking up complex tables like this into multiple tables (e.g., one table for each group). Multiple tables would likely be easier to read and understand, and are better supported by assistive technologies like screen readers.

glin avatar Mar 21 '21 23:03 glin

Thanks!! @glin

Ivy-ops avatar Mar 24 '21 20:03 Ivy-ops