eachTask not limited to parent id?

I’m trying to iterate over the immediate children using eachTask and supplying the parent, but it’s iterating over every record for some reason.

gantt.eachTask(function (child: any) {
//do something
}, parentId)

Hello,
You can use the parent property of the task. Using a condition, iterate over only the tasks you need:


function iteratesChild(parentId) {
    gantt.eachTask(
        task => {
            if (task.parent == parentId) {
                gantt.message(task.text)
            }
        },
        parentId
    );
};
iteratesChild(1);

Look at the example in the snippet: https://snippet.dhtmlx.com/bz7na2ul.
If you have additional questions, write to us, and we will try to help you.