-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Grid: colspan, rowspan support #123
Comments
Sorry @Guria. This isn't going to be implemented. I've considered it before and it would add a lot of complication. If you'd like to control this level of cell-sizing you should create your own high-order component wrapper around |
@bvaughn this is ok, since there is a way to acheive desired result. btw, which existing variant do you like more? |
I think your first variant, with |
Nice! If you run into performance issues with |
Oh @phahn, do you mind to share you solution with Collection? I have a problem with grid. I want to achieve both colspan, and rowspan |
Hey @hung-phan I have to see if I can share some code after the weekend but in the meantime here's what I'm doing: I have configuration objects for columns like I pass this list of With the information totalHeaderHeight, number of levels, current level and width of each For row spans the concept is similar. |
Interesting. Initially, I think it may be possible to do something similar with |
If you create a |
Out of interest, has anyone had any luck doing this within a grid? I am migrating a major angular 1.x project to React and am looking to do something like the following: IOW some non-fixed rows should span the entire grid and contain an SVG. At the moment I am pretty new to react-virtualized, so apologies if this has already been discussed. |
I don't really have enough info to say for sure @csvan, but I believe you might want to look into using |
@bvaughn I do need both horizontal and vertical scrollsync, since we will be rendering several thousand rows and columns at once. Sorry for not providing sufficient detail. I looked into alterative 2 in the OP, and it does approximately what I want (with some hacks). It's regrettable that it leaves redundant invisible columns, but there is no noticeable performance degradation so I can live with that. Will update here if I find a better solution. |
Thanks for the update!
For what it's worth, you can return |
@bvaughn awesome, thanks! |
@Guria @bvaughn unfortunately, I hit a roadblock. For example, if the Grid expects each cell to be 75px wide, and I force my "spanning" cell to be 1200px wide, it will still disappear when the first 75px (approx) are scrolled out the visible part. Is there any way I can tell the Grid to only remove elements after a certain scroll threshold? |
I don't really have a clear picture of what you're doing to be honest, but if you're using a custom |
@bvaughn I am using a MultiGrid so that I can have nice distinct column and row headers to render a spreadsheet-type grid. Working very nicely so far. I also have an upcoming requirement to support grouped columns. This would affect only how the cells are rendered in the top right Grid. I like some of your suggestions here like trying cellRangeRenderer and/or returning null for "invisible" cells. I haven't tried anything yet, but I was thinking of just trying to handle it in the cellRenderer by having the grouped column cell that spans multiple child columns inject a position: relative div that has the appropriate width. This allows it to bleed out of its containing div. Heck, maybe I could just modify the containing div's width directly. Needs more thought and experimentation. I like your response about being able to return null for "invisble" cells. |
@csvan @bvaughn I have made some progress with MultiGrid in trying to render grouped columns. The approach I started with follows some of the suggestions here:
It looked good until I started scrolling horizontally. I hit the same roadblock @csvan did. That is, when the spanning cell falls out of the viewport being rendered (because MultiGrid thinks it has a much smaller width), it disappears. I understand this behavior from the Grid's POV, but at this moment I am scratching my head. I guess I will investigate @bvaughn 's suggestion of using cellRangeRenderer. Haven't had any experience with that yet... |
Yes, I have done this. cellRangeRenderer is the solution I used and it works well. Just adjust the columnStartIndex to make sure it captures the first 'real' column. I also started with hiding cells, then returned null to prevent them rendering at all. Ends up quite a neat solution. |
@MarkBarbieri Thanks, Mark. Yes, I am starting down that path of using cellRangeRenderer. To render my grouped column headers above the leaf column, I think my strategy has to be to examine the columnStartIndex passed to my override of defaultCellRangeRenderer for the MultiGrid._topRightGridRef. Find the leaf column at that index and then walk up its ancestor chain of columns and if the "cell slot" for those ancestor columns have a columnIndex that is less than columnStartIndex, then I have to manually rerender those (in my screen shots above that means the 2 cells for Group 0 and Group 0.0) and push them on to the children returned from defaultCellRangeRenderer. Making progress... What could go wrong? (A common saying in our little pod of developers as the code then crashes and burns...) |
I used this approach to create a TV guide layout with the whole grid full of irregular blocks. I pre-processed the data and stored a 2D array with indices matching the column/row indices of the grid. Each array object stores whether the cell should be rendered, the width (which is really a columnSpan), the column index of the first visible cell for this element and the column index of the next visible cell. This provides easy manipulation of the focused element. For example, a cell the spans columns 8-12, it stores
For cellRangeRendered, I then looped through the rows to be rendered,
|
Wow this sounds like a really useful modification! I was looking for a component which can create timetables. I'd really appreciate any tips you could give me about modifying rect-virtualized to support this timetable approach! |
If any one is still interested in this. I have created a component with colspan and rowspan support with dynamic cell height. https://github.com/pisharodySrikanth/virtualized-table The component takes in data prop in a format similar to how we create the table in html. The dummy cells are hidden behind the rowspan div. This component has some caveats like the one mentioned by @pete-moss, border goes when the colspan / rowspan div is removed from the DOM. I handled this by showing border of the hidden dummy cells. This works because I don't need to vertically center align by rowspan div and knew beforehand that the content of the rowspanned cell is relatively smaller. Also, I have created a wrapper around cell measurer and I calculate the height of the cell with rowspan by using the sum of cache.rowHeight for the next rowSpan no.of rows. |
Thanks everyone for the advice. It turned out to implement a table with hierarchical columns. I forked "defaultCellRangeRenderer" with 3 changes:
I also used a separate Grid for the header, synchronized with the body via ScrollSync. |
Did you modify the entire cellRangeRendered or just the visible part of it. trying to the same as you here! |
Would you mind sharing a bit of your cellRangeRendered? @dkskv |
@pedromoter I signed all the differences in cellRangeRenderer with numbers.
// ... some code
// ... some code
// ... some code |
What I want to achieve:
variant 1
Use separate grid per each header row with
ScrollSync
:variant 2
override cell width in rendered content and hide "unused" cells
variant 3 (not available currently)
But would be great to have colspan, rowspan support in grid to avoid extra hidden cells in DOM.
Don't sure in implementation but one possible is:
The text was updated successfully, but these errors were encountered: