Our state of the art Gantt chart


Post by daniel.piret »

Hello,

We have implemented the import as per the example, but is it possible to load the data as "changes" so we can send the update using sync? currently it's loading all the data on the gantt but we need the user to confirm the save, what we would like is that users do the import, show the new gantt and then if he decides to save then press save and the new gantt is sent to the server along with all the changes, but currently it's showing the gantt as it was synced already and therefore the sync will not send anything to the server.

Thanks

Last edited by daniel.piret on Tue Nov 24, 2020 9:34 am, edited 1 time in total.

Post by pmiklashevich »

Hello,

The demo uses data property of the task store to load data initially
https://bryntum.com/docs/gantt/#Gantt/data/TaskStore#config-data

me.taskStore.data = tasks[0].children;

Please use "add" API method
https://bryntum.com/docs/gantt/#Gantt/data/TaskStore#function-add

me.taskStore.add(tasks[0].children);

Best wishes,
Pavel

Pavlo Miklashevych
Sr. Frontend Developer


Post by daniel.piret »

Thanks for your quick reply,

I've tried your suggestion but it breaks in the add method with the following error:

Uncaught (in promise) Error: Parent node with id _generatedClassDefEx1 not found, cannot add children.
    add StoreCRUD.js:393
    add StoreCRUD.js:388
    add StoreStm.js:96
    importData Importer.js:34
    onFileSelected GanttToolbar.js:510

I thought it was caused by not removing the previous tasks and tried this:

me.taskStore.removeAll(true);
me.taskStore.add(tasks[0].children);

With the same result, I've tried the add with the other stores and they seem to work, but the taskStore is crashing everytime, I've also tried other mpp files and same result, any suggestion?

Thanks


Post by pmiklashevich »

Hello,

Right, adding to a store works good for plain stores, but when we're talking about Gantt, the task store is a tree. Therefore another API method should be used. https://www.bryntum.com/docs/gantt/#Core/data/mixin/TreeNode#function-appendChild
For that please first take the root node of the task store and call appendChild method on it.
https://www.bryntum.com/docs/gantt/#Gantt/data/TaskStore#property-rootNode

// me.taskStore.data = tasks[0].children;
me.taskStore.rootNode.appendChild(tasks[0].children);

If you're following the demo approach, removing is not needed. Importer replaces the project with a new instance

// assign the new project to the gantt
me.gantt.project = project;

And in app.js we destroy the old one

// destroy old project
project.destroy();

I checked the appendChild method in our demo and it worked correct. Hope it will work for you too.

Best wishes,
Pavel

Pavlo Miklashevych
Sr. Frontend Developer


Post by daniel.piret »

Thanks for your reply, I've tested the new method using appendChild and it successfully imports the tasks, but I'm back to the original point where Gantt is not taking the new tasks as changes to the current project, therefore when I press sync it does not send the changes to the server, what am I missing here?

I'm using the same "Importer.js" that is in the ms import example,

Thanks,


Post by arcady »

One more change that needs to be done in Importer class is setting silenceInitialCommit to false on the project:

        const
            project = new me.gantt.projectModelClass({
                // data loading shouldn't be silent to make the project dirty
                silenceInitialCommit : false
            });

That is a new config introduced in v4.0.0. After that is started to work for me.

I think it makes sense to add that config to the demo out-of-the box. Here is a ticket I've made for that and for checking why the stores are not dirty after loading data w/ store.data = [...]: https://github.com/bryntum/support/issues/1968

Thank you for the feedback!


Post by daniel.piret »

Just to confirm that I've tested the full approach and now it's working, the only missing bit here is that the "undo" (stm) does not seems to take into consideration these new changes, but everything else works fine.

Thanks for your help


Post by pmiklashevich »

I'm glad to hear it works for you now! Indeed, current implementation of the Importer class does not support STM. I've opened a feature request to improve the Importer, even though it's not a part of the core classes and just provided as an example: https://github.com/bryntum/support/issues/1972

If you need help with custom importer implementation, you can request our professional services.

Pavlo Miklashevych
Sr. Frontend Developer


Post Reply