In our Angular application, we currently use version 5.6.8 of the Scheduler Pro.
As normal, we bind our resources directly into the HTML. So in the TS-file we have a variable
protected myResources!: Partial<MyCustomResource>[];
that is bound in the HTML to the bryntum-scheduler-pro tag using
[resources]="myResources"
Whenever the resources update, we update this variable in the TS-file and the UI is updating itself without any problem. Now we needed to add custom sorting logic. We did this in our component like the following:
@ViewChild(BryntumSchedulerProComponent, { static: true }) schedulerComponent!: BryntumSchedulerProComponent;
private scheduler!: SchedulerPro;
public ngAfterViewInit(): void {
this.scheduler = this.schedulerComponent.instance;
this.scheduler.store.onSort = ({ source, sorters, records }: any) => {
this.resourceSortColumn = sorters[0].field;
this.resourceSortDirection = sorters[0].ascending ? 'asc' : 'desc';
records.sort((a: any, b: any) => {
return this.dataProcessingService.compareResources(
a,
b,
this.resourceSortColumn,
this.resourceSortDirection
);
});
};
}
Also this on its own is working perfectly.
However, a problems arises, when we have already sorted a column and then change the myResources variable. Even when this variable is sorted correctly on setting it, the scheduler changes the sort again, but without triggering the onSort callback, what leads to the problem that our sorting is breaking in that case. So the question is: How can we prohibit the scheduler doing this in that case or what would be the event-handler we need to listen to, to sort the resources again in that case?
Thanks for your answer,
Eugen