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 grid] Allow to get row path in tree #5087

Closed
2 tasks done
githorse opened this issue Jun 1, 2022 · 3 comments
Closed
2 tasks done

[data grid] Allow to get row path in tree #5087

githorse opened this issue Jun 1, 2022 · 3 comments
Assignees
Labels
component: data grid This is the name of the generic UI component, not the React module! feature: Row grouping Related to the data grid Row grouping feature plan: Premium Impact at least one Premium user support: commercial Support request from paid users

Comments

@githorse
Copy link

githorse commented Jun 1, 2022

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Summary 💡

When using row grouping, I can get access to the underlying rows making up a group with apiRef.current.getRowGroupChildren(). In addition to this, I'd like access to the path or criteria used to group the rows; i.e., something like

[{field: "studio", value: "20th Century Fox"}, {field: "director", value: "James Cameron"}]

or maybe just

{studio: "20th Century Fox", director: "James Cameron"}

It would be nice if the row (or cell) click event itself just had these properties available, rather than having to jump through hoops with params.id and apiRef.current the way getGroupRowChildren() works:

type GroupRowClickEvent<T> = {
   children: T[]
   path:     {[field in keyof T]: T[keyof T]}
}

function handleGroupRowClick<T>({children, path}: GroupRowClickEvent<T>) { ... } 

Examples 🌈

No response

Motivation 🔦

I need to turn the path/criteria into a set of filters that I can then apply to the full data set on a separate drill-down screen.

Order ID 💳 (optional)

No response

@githorse githorse added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Jun 1, 2022
@flaviendelangle flaviendelangle added component: data grid This is the name of the generic UI component, not the React module! new feature New feature or request plan: Premium Impact at least one Premium user feature: Row grouping Related to the data grid Row grouping feature and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jun 2, 2022
@flaviendelangle flaviendelangle changed the title expose drill-down criteria used to create a group row [data grid] Allow to get row path in tree Jun 2, 2022
@flaviendelangle
Copy link
Member

flaviendelangle commented Jun 2, 2022

You can walk the tree to retrieve this information
See this example: https://codesandbox.io/s/data-grid-premium-forked-h7bxxl?file=/src/App.tsx

We could add a doc example because it seems to be a relatively common use case.

@flaviendelangle flaviendelangle added support: commercial Support request from paid users and removed new feature New feature or request labels Jun 2, 2022
@flaviendelangle flaviendelangle self-assigned this Jun 6, 2022
@flaviendelangle
Copy link
Member

I'm closing this issue, I had to write the exact same function in #4927, I will probably expose it

@githorse
Copy link
Author

@flaviendelangle could you comment on the best way to do this now? Is there a way to figure this out from onRowClick?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: data grid This is the name of the generic UI component, not the React module! feature: Row grouping Related to the data grid Row grouping feature plan: Premium Impact at least one Premium user support: commercial Support request from paid users
Projects
None yet
Development

No branches or pull requests

2 participants