Premium support for our pure JavaScript UI components


Post by Gowtham »

Hi Dev,
We are using Bryntum Gantt and Schedular pro in a SPA, we have an issue while setting data to the ProjectModel. The data is fetched through Ajax and set to the ProjectModel like below

let newProject = new ProjectModel({ ...projectConfig}),
        stores = [
          "timeRangeStore",
          "calendarManagerStore",
          "resourceStore",
          "eventStore",
          "assignmentStore",
          "dependencyStore",
        ];
      newProject.on("dataready", function (e) {
        if (newProject.stm.disabled) {
          newProject.stm.enable();
          newProject.stm.autoRecord = true;
        }
        if (oldProject && !oldProject.isDestroyed) {
            oldProject.removeAllListeners();
            oldProject.destroy();
          }
      });
      stores.forEach((storeName) => {
        let store = newProject[storeName],
          storeId = store.id;
        console.log(storeName);
        if (data[storeId]) {
          store.add(data[storeId]);
        }
      });
      setProject(newProject);
      

As you can see above we are creating a new projectModel. If we use the same project model we are getting some other issue like Id collision.
Once we set the data on the second time we are getting the below error.

LoadDataError.png
LoadDataError.png (212.61 KiB) Viewed 798 times

Kindle suggest us the better way to handle setting and getting data from Project model. We are not using the REST API backend instead we are using GraphQL to fetch the data and save the modified data from stores.


Post by mats »

As you can see above we are creating a new projectModel. If we use the same project model we are getting some other issue like Id collision.

Can you please provide a simple test case for us, so we can reproduce this issue?

You should use https://bryntum.com/docs/gantt/#Gantt/model/ProjectModel#property-inlineData to set inline data.


Post by Gowtham »

mats wrote: Thu Apr 08, 2021 8:47 am

As you can see above we are creating a new projectModel. If we use the same project model we are getting some other issue like Id collision.

Can you please provide a simple test case for us, so we can reproduce this issue?

You should use https://bryntum.com/docs/gantt/#Gantt/model/ProjectModel#property-inlineData to set inline data.

We have tried the same but the issue still exists

let projectData = {
        tasksData: data.tasks,
        resourcesData: data.resources,
        calendarsData: data.calendars,
        assignmentsData: data.assignments,
        dependenciesData: data.dependencies,
        timeRangesData: data.timeRanges,
      };
      let newProject = new ProjectModel(newProjectConfig);
      newProject.loadInlineData(projectData);

Post by mats »

We could not reproduce this issue. To assist you with your question, please provide more details including a runnable test case (as described in our support guidelines).

To get the fastest possible support, provide a simple test case based on our standard examples.


Post Reply