Skip to content

Conversation

@ekeuus
Copy link
Contributor

@ekeuus ekeuus commented Apr 1, 2021

This is an initial proposal to implement excel-like column grouping like mentioned in #765 , #1066, #1287, #458, #410, #2031

It implements a "parent" column logic where you define a wrapper column that inherits the width and positions of its children. This means that one does not have to define the column groups beforehand with widths, but most of the logic stays as it is now. The API is taken from react-table and I think this makes more sense than having it as a fixed colspan logic, which one would have to maintain outside. For us it is a MUST HAVE feature in this absolutely brilliant library so that's also why I decided to try and RFC.

Some minor cleanup probably needed regarding having separate height variables for the two headers and maybe testing it with grouping and other features together? IMHO: I wouldn't even make it work with grouping since those flows don't make sense together.

Example of how it looks:
https://media.giphy.com/media/hIG3uvfLYanhiXa18m/giphy.gif

ReactDataGrid.mp4

@ekeuus
Copy link
Contributor Author

ekeuus commented Apr 1, 2021

@amanmahajan7 @nstepien

*/
/** An array of objects representing each column on the grid */
columns: readonly Column<R, SR>[];
columns: readonly (Column<R, SR> | ParentColumn<R, SR>)[];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the POC.

I can foresee a few issues with this approach.

  1. It cannot handle more that 2 header rows
  2. It relies on unique key to match the parent and the child rows. What happens when a key does not match or column does not have a parent key.

I think a better api would be use an implicit relationship between header rows so something like

interface ParentColumn {
   name: '',
   children: Array<Column | ParentColumn>;
}

interface Column {
}

This way we can specify any level of nesting

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have started a PR based on the above idea. Let me know if the api handles your use case.

@ekeuus
Copy link
Contributor Author

ekeuus commented Apr 16, 2021 via email

@ekeuus
Copy link
Contributor Author

ekeuus commented Apr 16, 2021 via email

@nstepien
Copy link
Collaborator

Now that we have column.colSpan(), I think you can use that feature together with aa custom header renderer to achieve the desired outcome, no?

@ekeuus
Copy link
Contributor Author

ekeuus commented Apr 22, 2021 via email

@nstepien nstepien changed the base branch from canary to main May 26, 2021 15:22
@sandves
Copy link

sandves commented Aug 18, 2021

Would love this feature. Any activity on this?

@ekeuus ekeuus requested a review from nstepien as a code owner September 10, 2021 11:22
@alexey-koran
Copy link

alexey-koran commented Sep 29, 2021

Hi. Any updates? @nstepien

@ekeuus
Copy link
Contributor Author

ekeuus commented Oct 5, 2021

I might take a look at this today and see if I am able to implement it with the new API idea.

@alexey-koran
Copy link

I might take a look at this today and see if I am able to implement it with the new API idea.

Thank you!

@Anny88
Copy link

Anny88 commented Nov 30, 2021

Good afternoon! Also think that grouped column is a very needed feature, my team would also love this. If possible, could you please have a look again?

@teneon
Copy link

teneon commented Dec 4, 2021

Our project would also benefit from Column header groups. Any news on this?

@ekeuus
Copy link
Contributor Author

ekeuus commented Dec 5, 2021

I have a prototype open here #2684 but it has been kinda quiet for some time now

@paustint
Copy link

paustint commented Nov 20, 2022

I know it's a year later and this is unlikely to get picked up, but would love to see this feature.

I am in the process of moving from a different commercial grid provider and when I started refactoring one of my use-cases I realized this feature was missing.

Was hoping to have the ability to re-create the same experience, but will have to look at other ways of presenting the info.

EDIT: I am going to look into summary rows and see if I can use that to solve this use-case. 🙏
EDIT2: I was able to solve my use-case using summary rows and spanning columns. It feel kinda hacky and column resizing is buggy and doesn't work on the spanned columns. But it works well enough for now.

image

@hyusetiawan
Copy link

I would love to see this pushed through, I am also in the middle of a project that requires column-level grouping. Unlikely due to how old the PR is but one can dream :)

@baur
Copy link

baur commented Feb 12, 2023

@amanmahajan7, @nstepien

Ths lib Ideal for our project but needs Column header groups. Any news on this?

It cannot handle more that 2 header rows

yes, in our case we need more than 2 rows

@isaac-arb
Copy link

yeah, I could benefit with this feature too

@amanmahajan7
Copy link
Collaborator

This has been implemented now
#3287

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

Successfully merging this pull request may close these issues.