Open kronaemmanuel opened 7 months ago
Hello, What is the most efficient way to reload completely different data from the server?
For example, i'm doing this: ` public async loadResources(): Promise
if (!this.scheduler || !this.planningGraph) {
return loaded;
}
try {
//this.scheduler.suspendRefresh();
//this.assignmentStore.suspendEvents();
this.resourceStore.suspendEvents();
this.resourceStore.eventStore.suspendEvents();
this.resourceStore.destroy();//.removeAll(true);
//this.eventStore.suspendEvents();
await this.resourceStore.loadDataAsync(this.planningGraph.graph);
//this.resourceStore.data = this.planningGraph.graph;
// await this.loadResourcesDetails();
//setTimeout(async () => {
// // Load data after planning is loaded;
// this.scheduler?.suspendRefresh();
// await this.loadResourcesDetails();
// this.scheduler?.resumeRefresh(true);
//}, 100);
loaded = true;
}
catch (error) {
BootstrapDangerToast.show("Error loading resources");
}
finally {
//await this.resourceStore.commit();
//await this.resourceStore.project.commitAsync();
//await this.scheduler.project.commitAsync();
this.resourceStore.resumeEvents();
this.resourceStore.eventStore.resumeEvents();
//this.eventStore.resumeEvents();
//this.assignmentStore.resumeEvents();
//await this.scheduler.resumeRefresh(false);
}
console.timeLog("LoadResources");
console.timeEnd("LoadResources")
return loaded;
}`
Hi,
Gantt uses a scheduling engine that represents the schedule as a graph. The (normally) most costly part of loading data is when it is entered into the graph, it is also similarly costly to unjoin data from the graph later.
Because of that, you should not first remove data and then plug the new data in. Performance should be much better if the dataset is simply replaced. The most efficient way to replace the data of a single store is therefor simply resourceStore.data = newDataSet
(you should not need to suspend and resume events then).
If you receive data for multiple stores at the same time from your backend, you are instead better of using https://bryntum.com/products/gantt/docs/api/Gantt/model/ProjectModel#function-loadInlineData. That can populate multiple stores at once, updating the underlying graph and UI a minimal amount of times (as compared to once per store)
Steps to reproduce:
bryntum.query('gantt').taskStore.loadDataAsync(arr)
public async loadEvents(): Promise {
if (!this.scheduler || !this.planningGraph) { return false; }
this.compteur += 1;
console.time(
LoadEvents_${this.compteur}
); let loaded: boolean = false;try {
} catch (error: any) { if (error instanceof EdispatchException) { BootstrapDangerToast.show(ResourcesManager.manager.getString("Error"), error.title); } else { BootstrapDangerToast.show(ResourcesManager.manager.getString("Error"), error.toString()); } } finally {
}
console.timeEnd(
LoadEvents_${this.compteur}
); return loaded; }public async loadResources(): Promise {
console.time("LoadResources");
let loaded: boolean = false;
if (!this.scheduler || !this.planningGraph) { return loaded; }
try {
} catch (error) {
} finally {
} console.timeLog("LoadResources");
console.timeEnd("LoadResources") return loaded; }