Our state of the art Gantt chart


Post by Jeba »

Hi Dev Team,
In our project, We have shared the project data between Gantt and Scheduler Pro. In the process, we are trying to commit eventStore for which we are using the following code

project.eventStore.commit()

I have attached the screenshot of the issue I am getting. How to fix this issue?

Attachments
eventissue.png
eventissue.png (29.07 KiB) Viewed 624 times

Post by mats »

Please share a full test case so we can inspect your setup


Post by Jeba »

Hi Dev Team,
The data of the individual stores are loaded using axios. Now I'm trying to commit the individual stores, but when I try to commit the event store I'm getting the following issue "this.eventStore.getResourcesForEvent is not a function".

This is how i have loaded the data

componentDidMount() {
    console.log("panel mounted");
    let me = this,
        {
            current: container
        } = this.containerRef,
        project = (window.project = new ProjectModel(projectConfig));
    axios.get("datasets/tasks.json").then((result) => {
        let stores = [
                "dependencyStore",
                "assignmentStore",
                "eventStore",
                "resourceStore",
                "calendarManagerStore",
                "timeRangeStore",
            ],
            storesLoaded = {
                tasks: false,
                dependencies: false,
                assignments: false,
                resources: false,
                calendars: false,
                timeRanges: false,
            };
        stores.forEach((storeName) => {
            let store = project[storeName],
                storeId = store.id;
            store.clear();
            let onAdd = function() {
                console.log("add", arguments);
                storesLoaded[storeId] = true;
                let allStoresLoaded = true;
                for (var i in storesLoaded) {
                    allStoresLoaded = allStoresLoaded &&
                        storesLoaded[i];
                }
                if (allStoresLoaded) {
                    project.load().then(() => {
                        project.stm.enable();
                        project.stm.autoRecord =
                            true;
                        project.stm
                    .resetQueue();
                        project.resourceStore
                            .commit();
                        project.eventStore
                            .commit();
                    });
                }
                store.un("add", onAdd);
            };
            store.on("add", onAdd);
        });
        stores
            .slice()
            .reverse()
            .forEach((storeName) => {
                let store = project[storeName],
                    storeId = store.id;
                store.add(result.data[storeId].rows);
                store.trigger("load", {
                    data: result.data[storeId].rows
                });
            });
        
}); me.gantt = window.gantt = new Gantt({ ...ganttConfig, project, }); }

How to resolve this issue?


Post by saki »

We would need a showcase that we can run, investigate and debug to know the reason for that specific error you're getting.

However, the approach seems to be too complicated because you need to take care of the order of stores for load and commit. We already have methods for handling the data of whole project so we recommend to utilize them:

https://bryntum.com/docs/gantt/#Gantt/model/ProjectModel#function-commitAsync - use this if you want to commit all changes in one call. Mind please that this is an async method and that it triggers the project recalculation.

https://bryntum.com/docs/gantt/#Gantt/model/ProjectModel#function-loadInlineData - use this to load project data that has already been gotten from the server by Axios. Ideally, one Axios server call would load all necessary data the would be then fed into this method.


Post Reply