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?