I am trying to import an MPP with AutoSync enabled and am running into some troubles. The initial import works without any issues, but the esuing sync only sends a request with calendars and tasks, but without everything else.
I am using v4.0.7
Previously, after an import the sync would run with all of the information present in the mpp (dependencies, resources, etc). This allowed me to re-use the code on sync. However, now the only information that is synced are the rows.
What is the propsed way to deal with this?
This used to work in previous versions of the gantt and no longer works after updating.
I don't beleive that flag will have any impact because the gantt is loaded originally and then the user chooses to import their mpp file causing an ensuing sync. This doesn't seem like the initial commit to me.
The first one is misconfigured ProjectModel. It has to be set explicitly with silenceInitialCommit and transport:
async importData(data) {
const me = this;
const project = new me.gantt.projectModelClass({
silenceInitialCommit: false
// To save imported data provide `sync` url and set `autoSync` true, or call `gantt.project.sync()` manually after data is imported.
autoSync: true,
transport: {
sync: {
url: 'syncUrl'
}
}
});
The other problem is how the data is set to the stores. In the importer data is set to the store.data property. Which is a valid approach, but there is a bug that records added this way are not considered to be added. They are loaded. There is alternative solution to add records to the store. Flat store supports store.add function, tree store supports store.rootNode.appendChild. We will get the importer fixed in scope of this ticket: https://github.com/bryntum/support/issues/1968
Note, adding dependency should be done after tasks are added.
You can replace ".data = " "with .add(...)" and move "importDependencies" after "appendChild" in the importer
Thanks @pmiklashevich this was a ton of help! This is almost working, except for the fact that the calendar is ignored upon import. Prior to import the non-working days are highlighted properly in the gantt, but post import the days are ignored and a task that was scheduled for 4 days that crosses over a weekend now ends during the weekend. This means that the task end date is incorrect and all dependencies are also a bit off.
I have tried ignoring the calendar portion of the import and set the data of the calendarMangerStore to the data of the default projec that is loaded.
However, this new project still seems to ignore the calendar data and after setting the new imported project on the gantt project variable, the working days seem to be disregarded.
Please use "add" when set data to calendar manager store. If you download 4.1.0-beta-2 from customer zone, you'll find a new Importer.js file in the MSProjectImport demo. It uses "add" to update calendars:
You can try to zoom in to see if some hours are non working or not:
gantt.zoomIn(5); // in console of the demo
Снимок экрана 2021-02-26 в 11.43.59.png (56.19 KiB) Viewed 847 times
Please try out the new importer and let us know if it works for you. If not, please produce mpp file you test against, so we can see the problem. Thanks!