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] Implement Row spanning #207

Closed
1 task done
oliviertassinari opened this issue Aug 22, 2020 · 72 comments · Fixed by #14124
Closed
1 task done

[data grid] Implement Row spanning #207

oliviertassinari opened this issue Aug 22, 2020 · 72 comments · Fixed by #14124
Assignees
Labels
component: data grid This is the name of the generic UI component, not the React module! feature: Row spanning Related to the data grid Row spanning feature linked in docs The issue is linked in the docs, so completely skew the upvotes new feature New feature or request

Comments

@oliviertassinari
Copy link
Member

oliviertassinari commented Aug 22, 2020

TODO

Benchmarks

Screenshot 2023-03-02 at 01 02 57

Screenshot 2023-03-02 at 01 05 48

Screenshot 2023-03-02 at 00 58 57

Screenshot 2023-03-02 at 00 59 59

Screenshot 2023-03-02 at 01 00 26

User requests

@oliviertassinari oliviertassinari added component: data grid This is the name of the generic UI component, not the React module! new feature New feature or request labels Aug 22, 2020
@oliviertassinari oliviertassinari added the linked in docs The issue is linked in the docs, so completely skew the upvotes label Nov 30, 2020
@reginaldosantarosa

This comment has been minimized.

@daniel-refahi
Copy link

yes, please. such a useful feature

@oliviertassinari oliviertassinari changed the title [DataGrid] Implement Row spanning [data grid] Implement Row spanning Mar 16, 2022
@azeem-sarwar

This comment was marked as resolved.

@olavfosse
Copy link

(When) will this be implemented?

@olavfosse
Copy link

Also, will this be "Pro" or "Premium" feature?

@flaviendelangle
Copy link
Member

flaviendelangle commented May 6, 2022

Also, will this be "Pro" or "Premium" feature?

According to our Pricing page it will be available on all plans, so open source.

(When) will this be implemented?

We did not plan this feature yet. The Column Spanning has recently been released by the way.

@stellaliao01

This comment was marked as resolved.

@fpiaggio-ms

This comment was marked as resolved.

@Bindeep

This comment was marked as resolved.

@flaviendelangle
Copy link
Member

I would be interested to have a few examples of the use cases around row spanning

@ayaviri
Copy link

ayaviri commented Jul 1, 2022

I would be interested to have a few examples of the use cases around row spanning

i might have misunderstood the question, but one use case be to prevent the need for tool tip hovers such as these, which aren't accessible to keyboard users

@flaviendelangle
Copy link
Member

But in this example, there is no cell that spans across several rows.
Like on this example
Do we agree that the spanning would not only occur on interaction but would always take place ?

Otherwise, you are probably looking for variable row height or dynamic row height

@BatgerelBill

This comment was marked as resolved.

@mui mui deleted a comment from maxpham97 Aug 10, 2022
@stbaione
Copy link

Any updates on this feature? Would be very useful and is a pretty common table feature

@Rearden21M
Copy link

Upvoted — I needed this feature so I searched for it, only to find out that it's a long-awaited feature that has been "coming Soon™" for over 2 years. 🥲

@miguelpalacio
Copy link

@flaviendelangle, I believe this is a use case:

CleanShot 2022-09-13 at 19 12 16@2x

You guys actually have a very similar example for column spanning in your docs.

@dilipcm

This comment was marked as resolved.

@Crhist0

This comment was marked as resolved.

@straps

This comment was marked as resolved.

@BrianSparr

This comment was marked as resolved.

@hyukkyukang

This comment was marked as resolved.

@mamodev

This comment was marked as resolved.

@Di-Nazavr

This comment was marked as resolved.

@drjele

This comment was marked as resolved.

@cherniavskii
Copy link
Member

@oliviertassinari Yes, that's the plan - see https://www.notion.so/mui-org/xGrid-Support-new-use-cases-with-new-features-d05424cedf6f490eb547e6802c5f4a30

@moumine9

This comment was marked as off-topic.

@barrykaplan
Copy link

From a paying customer (yes, there are some of us), some insight the scheduling would be very helpful. We are running out of time and need to make a call whether to swap over to ag-grid or some such.

@jithinvariyar
Copy link

I needed this feature so I searched for it, only to find out that it's a long-awaited feature that has been "coming Soon™" for over 3 years. 🥲

@dzinreach
Copy link

Seems like this feature is still not implemented, even for the paid plans, right?
So, is there a hack to make row spanning for one-to-many record relationships work on the data grid?

@oliviertassinari
Copy link
Member Author

A quick workaround: https://codesandbox.io/p/sandbox/romantic-joji-7hhvfx?file=%2Fsrc%2FDemo.tsx%3A71%2C61

Screen.Recording.2023-11-27.at.18.34.40.mov

The API looks like this:

const rows = [
  {
    id: 1,
    lastName: "Snow",
    firstName: "Jon",
    age: 35,
    rowSpan: { age: 2 },
  },
  { id: 2, lastName: "Lannister", firstName: "Cersei", age: 42 },
  { id: 3, lastName: "Lannister", firstName: "Jaime", age: 45 },

It's implemented with a cell slot.

function MyCell(props: GridCellProps) {
  let style = {
    // TODO, shouldn't be needed, fix in the core.
    minWidth: props.width,
    maxWidth: props.width,
    minHeight: props.height,
    maxHeight: props.height === "auto" ? "none" : props.height,
    ...props.style,
  };
  const apiRef = useGridApiContext();
  const row = apiRef.current.getRow(props.rowId);
  if (row && row.rowSpan && row.rowSpan[props.column.field]) {
    const span = row.rowSpan[props.column.field];
    style = {
      ...style,
      minHeight: props.height * span,
      maxHeight: props.height * span,
      backgroundColor: "#fff",
      zIndex: 1,
    };
  }
  return <GridCell {...props} style={style} />;
}

@yehudamakarov
Copy link

everyone give kudos to @joserodolfofreitas for getting this on the roadmap!

@yehudamakarov
Copy link

yehudamakarov commented Dec 15, 2023

Does someone have another example (the first one being #207 (comment)) of how this feature would be used? This could help us once we create a demo in the docs. Thanks

  • Like @Legys 's use case, we need to have a few columns in the row render multiple cells per row.
    see this example of an array-type column rendering 3 elements in a cell (note that I manually pushed some cell content to the top):
    example of an array type column rendering x3 in a cell

  • Here I'm using @oliviertassinari 's workaround above but I don't know how to finish the row hovering for the spanned cells
    see the workaround example:
    example of spanning rows and rendering cells instead of an array type

  • I looked at the Tree Data and Row Grouping features to achieve this, but I want a different parent vs child row.

  • to work with the floor & room example above, then the "grouping column" would need to be more like a "grouping row."
    see a grouping example:
    example of the grouping column

for now

  • If someone can help get a cell to look like it is holding multiple cells, that would be special
  • Alternatively, it would be good to be able to use Tree Data but with a different parent and child, meaning different columns for parents and children.

@dzinreach
Copy link

My use case for the row spanning is for 1:Many record relationships on a report.

Think: Contacts < Cases < Documents

So the rowspan is based on checking the table id/key and the record id, so if the previous record has the same table id and record id, then it should be combined together into one row and rowspan for all of the other columns.

The real challenge is knowing the relationships between columns, and being able to have multiple tables with 1:Many relationships on the same data grid.

Imagine a Contact record spans 4 rows, because they have 4 Document Records, and the Document Records are spread over 2 Cases. So, each Case would have a rowspan of 2.

I’ve set this up in a custom .NET C# reporting platform, which checks the parent_table_id on each column and then the table_id and rec_id on each row.

@oliviertassinari
Copy link
Member Author

oliviertassinari commented Jan 11, 2024

Regarding the behavior with filtering, we might want the same as with Excel:

Screen.Recording.2024-01-11.at.02.19.49.mov

Rows span is not just a matter of expending to the next row, but about linking two twos together. When one is filtered, no span, when sorting changes their position, likely no span as well.

@alexvazquez

This comment was marked as resolved.

@Katsuchiyo
Copy link

Any estimation on timeline of the feature?

@jeffreyschultz
Copy link

jeffreyschultz commented Jun 5, 2024

Bumping. This feature would great as we are trying to replicate a real-world form within the data grid, and it has extreme row nesting under parent call values to aggregate the children under the same group.

Would anyone from the team be willing to drop some thoughts about how this would be implemented if someone from the community would like to work on a PR? @flaviendelangle @joserodolfofreitas

@jeffreyschultz
Copy link

@flaviendelangle @joserodolfofreitas

Is there someone that I need to email or call because I pay for the premium license, and for my comment to not even so much as get a response is not acceptable.

@joserodolfofreitas
Copy link
Member

@jeffreyschultz, I will reach out to arrange a short user interview. We'd love to better understand your use case.

@Katsuchiyo, we're wrapping up pivoting, and after that, we'll tackle Row spanning, so we're loosely talking about the possibility of releasing it next quarter (Q3 2024).

@jeffreyschultz
Copy link

jeffreyschultz commented Jun 26, 2024

@joserodolfofreitas

I believe that my use case is a bit more advanced than just row spanning, but it is needed none the less. Here is an excel mockup of a current process artifact that is captured within the security field. We are attempting to convert a manual process that is captured on paper into a more automated workflow, and are attempting to replicate the original form as much as possible to ease adoption.

image

You will notice that Event aggregates Indicator, and Indicator aggregates Action. Every Action is essentially its own row (includes Est. Location, Start Time, End Time, Assignment, and Act. Location), however, they are nested under their parent which groups them together. The odd column you will probably notice is Decision, and this is scoped to the entire Indicator--a specific decision needs to be made once an Indicator has been confirmed.

We also dynamically build the columns under Assets based on what is available to that team. So the number of columns is determined by backing data elsewhere in the app.

I believe that the following is beyond the scope of row spanning, however, I am providing it for completeness to give you better insight into what we would be trying to achieve.

  1. We want to provide the ability to directly add/remove new Event, Indicator, and Action rows within this grid, which almost seems as though a tree data structure would be best for easier management of the backing data.

  2. We want to support drag and drop of nested Indicator and Action rows to new parents; in the event of Indicator, that would be another Event, and for Action, that would be another Indicator.

  3. It would be great if sorting honored the nesting of the rows, so that Action rows sorted under its' Indicator, and Indicator rows sorted under its' Event.

Can this visual design be easily achieved with what is available in the Data Grid at this time? If so, would you be able to point me to someone that could provide some advice?

@vladyslav-n
Copy link

Upvoting

@joserodolfofreitas
Copy link
Member

@jeffreyschultz, thank you very much for sharing your use case!

  1. We want to provide the ability to directly add/remove new Event, Indicator, and Action rows within this grid, which almost seems as though a tree data structure would be best for easier management of the backing data.

We initially thought about the idea that row spanning is reflected in the data with repeated values on each row, like in the following example:

x-ray-rowspanning

But we may indeed need a way to define the hierarchy of cells to support your following described scenarios.

  1. We want to support drag and drop of nested Indicator and Action rows to new parents; in the event of Indicator, that would be another Event, and for Action, that would be another Indicator.

That's an interesting use case, unfortunately, outside the scope of the initial version, but we'll keep an eye out for a workaround (It's a tough one though).

  1. It would be great if sorting honored the nesting of the rows, so that Action rows sorted under its' Indicator, and Indicator rows sorted under its' Event.

That's also an interesting use case. We're not planning to constrain sorting like this by default, but we can likely provide a recipe using a custom comparator.

Can this visual design be easily achieved with what is available in the Data Grid at this time? If so, would you be able to point me to someone that could provide some advice?

That's not supported at this time, and although Row spanning is one of the highest priorities for the next quarter, I'm afraid the initial version won't have out-of-the-box support for these most advanced use cases based on a defined hierarchy. Even the bolder borders on the created groups might be challenging.
But as mentioned before, we'll try to find workarounds within the initial implementation so your use case can be unblocked. And we'll certainly consider a follow-up to support such use cases out-of-the-box. Thanks again for sharing it.

@jeffreyschultz
Copy link

@jeffreyschultz, thank you very much for sharing your use case!

  1. We want to provide the ability to directly add/remove new Event, Indicator, and Action rows within this grid, which almost seems as though a tree data structure would be best for easier management of the backing data.

We initially thought about the idea that row spanning is reflected in the data with repeated values on each row, like in the following example:

Yeah, that was one of my thoughts as well. It would certainly make it easier from your side to handle that. You mark which columns are to group, and then the cell renders a rowspan attribute for that number of rows along with ensuring the sort brings those rows together.

It seems to me that a combination of styling changes, row grouping, and row spanning could possibly get me most of the way there? The row grouping layout is different than what I am looking for, but is it possible change the rendering to something more like this? Instead of a dropdown, you get a row spanned cell?

@joserodolfofreitas
Copy link
Member

joserodolfofreitas commented Jun 27, 2024

It seems to me that a combination of styling changes, row grouping, and row spanning could possibly get me most of the way there? The row grouping layout is different than what I am looking for, but is it possible change the rendering to something more like this? Instead of a dropdown, you get a row spanned cell?

@jeffreyschultz, yeah, maybe you can use multiple grouping columns. Now, honestly, I think it seems close enough, but it's deceivingly hard to move from the drop-down to the row-spanning display. We'll discuss some alternatives and let you know.

We can keep the discussion about this use case on #13646.

@MBilalShafi MBilalShafi self-assigned this Aug 7, 2024
@MBilalShafi MBilalShafi added the feature: Row spanning Related to the data grid Row spanning feature label Aug 21, 2024
Copy link

This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue.
Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.

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 spanning Related to the data grid Row spanning feature linked in docs The issue is linked in the docs, so completely skew the upvotes new feature New feature or request
Projects
Status: Done
Status: In progress now
Development

Successfully merging a pull request may close this issue.