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.

https://docs.dhtmlx.com/gantt/api__gantt_gettaskposition.html

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”, child.id);
el.style.left = sizes.left + ‘px’;
el.style.width = sizes.width + 10 + ‘px’;
el.style.top = ‘32px’;
main_el.appendChild(el)
}
}, task.id)
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