I’m developing an app to manage a large set of requirements, and I’m looking for advice on the best way to implement a Hierarchical List or Tree Structure. Each requirement has a parent (main section) and, optionally, a grandparent (subsection). While the ability to go multiple levels deep would be great, it’s not essential for this particular project.
Key Considerations:
Screen real estate: To keep the UI clean and uncluttered, I want to avoid using extra columns to visualize the main section and subsection for each item. Instead, I’d like to use a Hierarchical List for better organization and clarity. (Screenshots attached below for reference.)
Requirements:
Each item should have a parent, and potentially a grandparent, as well as siblings and an index.
When a new item is added, it must automatically:
Be assigned a parent (unless it’s a main section).
Receive the next available index within its parent section.
When an item is removed, the indexes of the remaining items should automatically recalculate.
Items should be re-assignable to a different parent, with indexes recalculating accordingly.
Items should be reorderable (moved up or down) within their sibling list.
Attempts So Far:
Approach 1:
This method meets all the requirements above but has significant performance issues. It’s slow to load and heavily reliant on calculated rows, making maintenance more complex.
Approach 2:
This system is much faster but doesn’t support automatic recalculation of indexes when items are removed or reassigned to a new parent.
What I Need Help With: Before spending more time experimenting, I’d love to hear how you experts might tackle this challenge. Would a JavaScript column be a potential solution for this use case? Should I migrate to SQL? Or has anyone successfully implemented a similar setup in Glide that balances performance and functionality?
Any advice, best practices, or examples would be greatly appreciated. Thanks so much for your help!
I think your case points to “when to use a SQL or NoSQL database”. This article can help you a lot
Many times we want to create our APP using a SQL structure in Glide and it’s is fine (although Firebase, the core of Glide Tables, is a NoSQL database ) but sometimes use JSON to gather and search data is a better idea and fastest solution.
Thanks for your feedback, greatly appreciated!
Perhaps indeed I could use a bit less columns&relations if I would work with JSON objects. But I would need to think about it, will keep you posted if I found a good solution!
I think 1-4 is fairly straight forward, and I can immediately think of a fairly elegant solution for that.
But item 5 increases the complexity quite a bit. There are a few different approaches to manual reordering, but combining any of them with the first 4 requirements will take quite some doing.
Thanks for you support in this, I used the input of @Andrew_Davies and built on top of it.
I know have something that has the least complexity possible I think and that works well.
Here’s a quick movie about it, if you would want to build something similar and you need more info, or you have an even better way to do this let me know!
Watching your video, I’m accidentally seeing a way to create a Gantt chart setup (table, tasks) and/or reorder its tasks on the fly.
I can’t find a better way to complete a Gantt chart setup like your proposal.
Thanks @Andrew_Davies as well, your idea reminded me of some old software I used 15 or 20 years ago that used the same technique on its dBase IV tables when a new record was added or reordered.