Our state of the art Gantt chart


Post by rahulranjan »

Hi
Is it possible to get all the leafs nodes from selected task .

Post by pmiklashevich »

Please open https://bryntum.com/examples/scheduler/tree/ demo, select a resource (Terminal A for example), and run in console:
result = []; scheduler.selectedRecord && scheduler.selectedRecord.traverse(node => node.isLeaf && result.push(node));
Check the `result`
result.map(node => node.name)
// ["Gate 1", "Gate 2", "Gate 3", "Gate 4", "Gate 5", "Gate 6", "Gate 7", "Gate 8", "Gate 9", "Gate 10"]
Docs here:
https://www.bryntum.com/docs/scheduler/#Common/data/mixin/TreeNode#property-isLeaf
https://www.bryntum.com/docs/scheduler/#Common/data/mixin/TreeNode#function-traverse

Pavlo Miklashevych
Sr. Frontend Developer


Post by rahulranjan »

Thanks it works
One more question can i get all the parents of a task for example

N1
->N2
->N3
->T4

I want all the parents of T4 and it should return N1,N2,N3 including root node

Post by pmiklashevich »

Please select Gate 1 and run in console:
parent = scheduler.selectedRecord && scheduler.selectedRecord.parent;
result = [];
root = scheduler.resourceStore.rootNode;
while (parent) {
    result.push(parent);
    parent = parent.parent;
}
result.map(node => node === root ? 'root' : node.name)
//["Gates 1 - 5", "Terminal A", "Kastrup Airport", "root"]

Pavlo Miklashevych
Sr. Frontend Developer


Post Reply