glide-data-grid icon indicating copy to clipboard operation
glide-data-grid copied to clipboard

Hierarchical Data / Tree Data

Open Fee0 opened this issue 2 years ago • 9 comments

It would be nice to be able to display some hierarchical data like a file/folder structure. Something similar to what AG-Grid is doing here: https://www.ag-grid.com/javascript-data-grid/server-side-model-tree-data/

Data hierarchy is represented like this:

grafik

And table looks like that:

grafik

It would probably makes sense to restrict the area to toggle the hierarchy in the cell, such that the cell can also be normaly interacted with via double click or similar. Maybe lazily loading the data of collapsed hierarchies when uncollapsing them would increase performance.

Fee0 avatar May 28 '22 19:05 Fee0

Representing trees is not overly difficult save for the flattening. I want it to be automatic from the data structure but maybe starting by letting the user flatten the data first is enough to start.

jassmith avatar May 28 '22 19:05 jassmith

In addition, and maybe as a step toward tree-likee data, would be simple nested tables ?

ccollie avatar Jun 02 '22 19:06 ccollie

That would break selection pretty heavily.

jassmith avatar Jun 02 '22 19:06 jassmith

That would break selection pretty heavily. I see. I would even settle for row expansion.

ccollie avatar Jun 02 '22 19:06 ccollie

What do you mean by row expansion?

jassmith avatar Jun 02 '22 20:06 jassmith

Something like:

https://jbetancur.github.io/react-data-table-component/?path=/story/expandable-basic--basic

ccollie avatar Jun 02 '22 21:06 ccollie

Oh yeah, thats definitely not high on my priority list, the original suggestion here is something I think we can do without too much pain. Next time I get a free 4 or 5 hours I think I can make a demo and maybe someone can help bring it over the line.

jassmith avatar Jun 02 '22 21:06 jassmith

Fair enough, and thanks for your effort. It looks fantastic !

ccollie avatar Jun 02 '22 22:06 ccollie

This is something you can implement yourself using the existing API. I built a version of this for a project, and just posted a pared down example in #358.

https://user-images.githubusercontent.com/94077014/171967439-0a3a2193-eef4-4c4b-aff9-ee0dced9f462.mp4

Essentially I take the tree data and flatten it into an array of items, adding a "depth" value and skipping the children of collapsed items. A custom cell renderer then draws the text and triangle with the appropriate indentation and collapsed state, and an onCellClicked handler checks if the triangle is clicked and then toggles the "collapsed" state of the item.

pzcfg avatar Jun 03 '22 23:06 pzcfg

This is now possible in 6.0.0 with some manual work. However there are more improvements expected.

jassmith avatar Dec 17 '23 23:12 jassmith