Our state of the art Gantt chart


Post by mats »

If you go back to the docs, it's explained there: https://bryntum.com/docs/gantt/#Gantt/model/TaskModel#property-convertEmptyParentToLeaf-static

By specifying true, all empty parents will be considered leafs. Can also be assigned a configuration object with with the following Boolean properties to customize the behaviour:

onLoad - Apply the transformation on load to any parents without children (children : [])
onRemove - Apply the transformation when all children have been removed from a parent

TaskModel.convertEmptyParentToLeaf = {
    onLoad   : true,
    onRemove : true
}

Post by amit_896 »

On load how we can convert tasks in summary dynamically, not for all tasks but some based on some conditions


Post by mats »

This is not supported, why not handle this on the server side instead for initial load case?


Post by amit_896 »

do we need to pass any property from the server, like isLeaf = false


Post by pmiklashevich »

isLeaf is a property to check if the node is a leaf node or a parent node.

To load a node as a leaf node just omit setting children field. We will update our docs to make it clear.

Cheers!

P.S. since convertEmptyParentToLeaf is true by default for TaskModel, you can even set the children to an empty array. It will be automatically converted to a leaf node.

Pavlo Miklashevych
Sr. Frontend Developer


Post by amit_896 »

You mean Task with empty children array will get treated as summary Task, correct?

Task:{
        children: []
}

Post by pmiklashevich »

Nope, convertEmptyParentToLeaf is true by default for TaskModel. That means when the task is loaded to the store, it will be automatically converted into a leaf task. If the desired behaviour is to keep it a summary task, set convertEmptyParentToLeaf to true. For example, modify Gantt/examples/_datasets/launch-saas.json
and set children to an empty array for "Setup web server" task:

"id": 1,
"name": "Setup web server",
"percentDone": 50,
"duration": 10,
"startDate": "2019-01-14",
"rollup": true,
"endDate": "2019-01-23",
"expanded": true,
"children": [],

Then open the demo to check the result:

Снимок экрана 2021-06-15 в 12.58.22.png
Снимок экрана 2021-06-15 в 12.58.22.png (130.25 KiB) Viewed 419 times

Now modify Gantt/examples/advanced/lib/Task.js and add to the bottom of the file:

Task.convertEmptyParentToLeaf = false;

Reload the page in the browser:

Снимок экрана 2021-06-15 в 13.00.09.png
Снимок экрана 2021-06-15 в 13.00.09.png (148.22 KiB) Viewed 419 times

Please see the difference

Pavlo Miklashevych
Sr. Frontend Developer


Post Reply