Our blazing fast Grid component built with pure JavaScript


Post by valereimann »

Hi,
I have a TreeGrid (v7.2) with checkbox selection. I want to add a "Show selection only" menu item to the header menu that hides every row except the ones the user has checked — no parent rows, just the selected records as a flat list.

1 store.chainTree(record => selectedIds.has(String(record.id)))

I added debug logging and found that the filter callback is only ever invoked for leaf nodes — records that have no children in the tree. Records that have children are silently skipped and never passed to the filter function at all.
This means if a user selects a node that has child records, that node will never be tested against the filter → 0 matches, empty grid.

// Tree: Root → Parent (has children) → Child (leaf)
// selectedIds = Set {"parent-id"}

store.chainTree(record => {
  console.log('checked:', record.id); // only logs "child-id", never "parent-id"
  return selectedIds.has(String(record.id));
});
// result: empty store

Is this the intended behavior of chainTree, or am I misunderstanding the API? The docs say "only child nodes which pass the chainedFilterFn will be considered" — does "child nodes" specifically mean leaf nodes only?

2 store.filter({ filterBy: fn })
This shows parent nodes automatically whenever any of their children match (the well-known tree filter behavior), which is exactly what we don't want.


3 Current workaround:

I build a brand-new Store containing only the selected records' data with children and parentId stripped:

const selectedData: any[] = [];
for (const r of selectedRecords) {
  const raw = { ...(r.data ?? r) };
  delete raw.children;
  delete raw.parentId;
  selectedData.push(raw);
}
grid.store = new Store({ tree: true, data: selectedData });

This works — the grid shows only the selected records as a flat list — but it feels like a workaround. The original store is saved and restored when the user clicks "Show all".

Question:
Is there an official / recommended API in Bryntum 7 to display only specific records in a TreeGrid (regardless of their position in the hierarchy), completely suppressing all ancestor/parent rows? Something like chainTree but for non-leaf nodes?


Post by tasnim »

Hi there,

As far as I know, there isn’t a dedicated API in Bryntum 7 that works exactly like chainTree for non-leaf nodes while completely omitting their parent/ancestor records.

If your goal is to display only specific records regardless of hierarchy, one approach you can try is to disable the tree feature when applying your filter. This way, the grid behaves more like a flat structure and will only show the filtered records without preserving the parent-child relationships.

Let us know if that approach works for your use case

Best regards,
Tasnim

How to ask for help? Please read our Support Policy


Post by valereimann »

Hi,
Thanks for the suggestion, but unfortunately features.tree.disabled = true does not work — it throws a runtime error:

Error: Tree feature cannot be disabled
    at Tree.doDisable (Tree.js:99)

I checked the Bryntum source code (@bryntum/grid-thin/lib/feature/Tree.js) and found this is hardcoded intentionally:

doDisable(disable) {
    if (disable) {
        throw new Error('Tree feature cannot be disabled');
    }
}

The JSDoc for the Tree feature also states:
"This feature is disabled by default. When enabled, the feature cannot be disabled during runtime."

So the approach you suggested is not possible in Bryntum 7.

Do you have another idea?

Best regards,
Valentin


Post by mats »

You'll need to wait for this issue to be implemented, we'll try to prioritize it: https://github.com/bryntum/support/issues/3609


Post by valereimann »

Hi Mats,
thanks for the clarification.
We purchased Bryntum support specifically to resolve this issue, since this functionality is critical for our use case.

The feature request (#3609) has been open and marked as high‑priority since October 22, 2021, so we were hoping for more concrete guidance.
Could you please share whether there is an expected timeline or target release for when this will be implemented? Even a rough estimate would help us plan, as this currently blocks us from delivering required functionality without relying on workarounds.
Thanks in advance for any update.

Best regards,

Valentin


Post by mats »

Thanks for the feedback - we'll see if this can be fast-tracked, sorry for the wait!


Post Reply