Our state of the art Gantt chart


Post by peterlechner »

Hi,

can you provide a sample with the correct way for moving nodes within a children collection.
I would like to simulate drag & drop.

My current approach for move down

    let selectedRecord = ganttControl.selectedRecord;

if (selectedRecord && selectedRecord.nextSibling) {
    let parentRecord = selectedRecord.parent;
    let nextSibling = selectedRecord.nextSibling;

    parentRecord.removeChild(nextSibling, true);
    parentRecord.insertChild(nextSibling, selectedRecord);
}

My current approach for move up

    let selectedRecord = ganttControl.selectedRecord;

if (selectedRecord && selectedRecord.previousSibling) {
    let parentRecord = selectedRecord.parent;
    let previousSibling = selectedRecord.previousSibling;

    parentRecord.removeChild(selectedRecord, true);
    parentRecord.insertChild(selectedRecord, previousSibling);
}

Nodes seem to move correctly. But the WBS-Codes are messed up.

Thanks, Peter


Post by mats »

No need to remove before inserting, this will suffice:

    parentRecord.insertChild(nextSibling, selectedRecord);

Please see https://bryntum.com/docs/gantt/api/Gantt/data/TaskStore#config-wbsMode to configure how WBS should update after CRUD operations.


Post by peterlechner »

Perfect, Thanks!
Peter


Post Reply