Our state of the art Gantt chart


Post by Qwerty »

If an event listener is added to beforeTaskEdit and it returns false, the event will not fire again

Example based on the "Basic demo"
import { Gantt, ProjectModel } from '../../build/gantt.module.js?435054';
import shared from '../_shared/shared.module.js?435054';
/* eslint-disable no-unused-vars */

const project = new ProjectModel({
    transport : {
        load : {
            url : '../_datasets/launch-saas.json'
        }
    }
});

let gantt = new Gantt({
    appendTo : 'container',

    project : project,

    columns : [
        { type : 'name', field : 'name', width : 250 }
    ]
});


gantt.on('beforeTaskEdit', () => {console.log('open'); return false;});

project.load();
"open" will only be printed to the console the first time the task editor is opened.

I have done some investigation and this is because in TaskEdit.js on line 148 there is `me._editing = true;` but then when it detects the return false on line 172 it does not set editing back to false and there seems to be no way to set this value from outside the library so it becomes stuck in edit mode. I have modified the source to simply set `me._editing = false;` just before it gets to the return which has solved the issue for me so this is not an urgent problem but it would be good to have a proper way to deal with this without having to modify the library code.

Post by mats »


Post Reply