Our state of the art Gantt chart


Post by lanpeng »

Hi bryntum team
I made some initial settings for the beforeAdd method, but it also triggered the beforeAdd method when dragging the task. But this is not what I want. How can I avoid it?

this.gantt.taskStore.on('beforeAdd', ({ records, ...data }) => {
            records[0].effort = 0;
            records[0].duration = 1;

    });
Attachments
Media1.mp4
(1.95 MiB) Downloaded 27 times

Post by johan.isaksson »

Hi,

When reordering rows, it is added at the new location. So technically it is expected to trigger beforeAdd. With that said, there should anyway be a way to distinguish the two operations also on the data layer. I suggest checking if the record already has a parent, pretty sure a newly added wont at this stage. Try something like this:

this.gantt.taskStore.on('beforeAdd', ({ records }) => {
    const [ task ] = records;
    if (task.parent) {
        // Reorder 
    }
    else {
        // Add
    }
});
Best regards,
Johan Isaksson

Post Reply