Get task position returning width of 0

I’m using the get task position in a getEachTask, but the width is returning 0. The children are rendered as split tasks, so I’m wondering if that’s the issue? If I try and create a layer directly from the split tasks they never seem to find the tasks.

const main_el = document.createElement(‘div’);
gantt.eachTask(function (child: any) {
if (child.entityname === “child_related” && child.related_start_date !== “” && child.related_end_date !== “”) {
var sizes = gantt.getTaskPosition(child,child.related_start_date,child.related_end_date);
var el = document.createElement(‘div’);
el.className = ‘adjustmentRelatedDates’;
el.setAttribute(“data-value”,; = sizes.left + ‘px’; = sizes.width + 10 + ‘px’; = ‘32px’;
return main_el

Right I’ve found other forum posts about this not working for split tasks and so have updated the code to use the parent task and that’s now working.

var sizes = gantt.getTaskPosition(task,child.related_start_date,child.related_end_date);

1 Like