Our state of the art Gantt chart


Post by amit_896 »

Hello,

We want to use the "convertEmptyParentToLeaf" property, where exactly we can use this after loading data from API

thanks


Post by mats »

You can see here: https://bryntum.com/docs/gantt/#Gantt/model/TaskModel#property-convertEmptyParentToLeaf-static

It is a static property you modify on your Task Model class. The docs has code snippets showing how.

TaskModel.convertEmptyParentToLeaf = false;

Post by amit_896 »

Thank you, Mat,

We added the "convertEmptyParentToLeaf " property in the Backend response model as well as the front-end Task model but changes can't reflect.

there any other place that needs to be change?


Post by mats »

Ok it's not a back end flag. You need to change the Task Model you use. Use basic JS imports:

import TaskModel from '../../lib/Gantt/model/TaskModel.js';
TaskModel.convertEmptyParentToLeaf = false;

Post by amit_896 »

Please see below screenshot

image (4).png
image (4).png (121.13 KiB) Viewed 522 times

Do you mean this one?


Post by amit_896 »

image (5).png
image (5).png (75.86 KiB) Viewed 521 times

also we set TaskModel.convertEmptyParentToLeaf = false; in above screen shot
it also won't work


Post by mats »

Yes but put it on your class Task. Also, why do you redefine all the default fields we have declared? It makes no sense to redefined those fields and use 'dataSource' like that. Use dataSource when you want to map a data field to another property in your data object.


Post by amit_896 »

we added in our task class which extending the task model, Still it's not converting in leaf.


Post by mats »

Just tried this in our basic sample, works great - please try it:

new Gantt({
    appendTo : 'container',

project,

dependencyIdField : 'sequenceNumber',

columns : [
    { type : 'name', width : 250 }
],

// Custom task content, display task name on child tasks
taskRenderer({ taskRecord }) {
    if (taskRecord.isLeaf && !taskRecord.isMilestone) {
        return taskRecord.name;
    }
}
});

project.taskModelClass.convertEmptyParentToLeaf = false;

Post by amit_896 »

Yes, it's working mats on removed all children parent is converted into leaf

now one more query how we can convert into leaf on load by default if there no children,

basically, this is the main goal we have been trying on this


Post Reply