Frontmatter
| id | 9406 |
| title | Create `Neo.data.TreeStore` |
| state | Closed |
| labels | enhancementaicore |
| assignees | tobiu |
| createdAt | Mar 9, 2026, 11:44 AM |
| updatedAt | Mar 9, 2026, 2:38 PM |
| githubUrl | https://github.com/neomjs/neo/issues/9406 |
| author | tobiu |
| commentsCount | 3 |
| parentIssue | 9404 |
| subIssues | [] |
| subIssuesCompleted | 0 |
| subIssuesTotal | 0 |
| blockedBy | [] |
| blocking | [] |
| closedAt | Mar 9, 2026, 2:38 PM |
Create Neo.data.TreeStore
tobiu added parent issue #9404 on Mar 9, 2026, 11:44 AM

tobiu
Mar 9, 2026, 12:09 PM
Input from Gemini 3.1 Pro:
✦ Implementation Guidance for Agents:
The core architectural mandate for the
TreeStoreis to allow theNeo.grid.Bodyvirtual scroller to function without modification.
- The Flattened View: The
GridBodyiterates over the store'sitemsarray. Therefore, theTreeStoreMUST override or manage its internal_itemsarray to only contain the currently visible nodes (root nodes + children of expanded nodes).- O(1) Lookups: You must implement a private
#childrenMap = new Map()keyed byparentIdto ensure that when a node is expanded, retrieving its children to inject into the flattened view is an O(1) operation. Do not usestore.filter()to find children during an expand operation.- Mutations: Expanding or collapsing a node should update the flattened view and fire a
mutateevent so the grid automatically recalculatesaria-rowcountand scrollbar height.Important Files to Reference:
src/collection/Base.mjs(Understandspliceandmutateevents).src/grid/Body.mjs->createViewData()(Understand how the grid maps the 1D array to the DOM).
tobiu assigned to @tobiu on Mar 9, 2026, 12:10 PM
tobiu cross-referenced by #9413 on Mar 9, 2026, 12:33 PM

tobiu
Mar 9, 2026, 2:38 PM
Input from Gemini 3.1 Pro:
✦ Implemented
Neo.data.TreeStorewith the "Splice Approach".
- Introduces
#childrenMapand#allRecordsMapfor data integrity and fast lookup.- The internal
_itemsarray (used byGridBody) dynamically flattens only the visible nodes viaCollection.splice().- Implemented
expand(),collapse(), andtoggle()functions for fast virtual scrolling recalculation without a full store filter.- Added
singleExpandbehavior.Changes pushed to
dev.

tobiu
Mar 9, 2026, 2:38 PM
Implemented Neo.data.TreeStore. Pushed to dev.
tobiu closed this issue on Mar 9, 2026, 2:38 PM
Goal
Create a specialized store to manage hierarchical data and provide a flattened view for virtual scrolling.
Details
src/data/TreeStore.mjsNeo.data.Store#childrenMap(Map) keyed byparentIdto enable O(1) child lookups.expand(nodeId): Updates node state, retrieves children, injects them into the flattened view, and fires amutateevent.collapse(nodeId): Reverses the expansion, recursively removing visible descendants from the flattened array.toggle(nodeId): Toggles the expanded state.loadData(data): Overridden to populate the internal#childrenMap.singleExpand(Boolean): Support for accordion-style expansion (expanding one node collapses siblings).