Page 1 of 1

[ANGULAR] Error when drag and drop event

Posted: Tue Aug 16, 2022 11:55 am
by nico-priv

Hello,
I have an error when i drag and drop an event.
It's works fine for one drag and the second this error appear.

Drag error.png
Drag error.png (176.1 KiB) Viewed 320 times

I don't know what the problem is, I updated the schedule to version 5.1.0 and since then I have this error.


Re: [ANGULAR] Error when drag and drop event

Posted: Tue Aug 16, 2022 11:59 am
by mats

Tried 5.1.1? Can you please upload a small test case for us?


Re: [ANGULAR] Error when drag and drop event

Posted: Tue Aug 16, 2022 12:07 pm
by nico-priv

Sorry, it's complicated to make a test case of my project. I will try. But I think my problem may be the way I populate the schedule.
"this.schedu" is my scheduler.

this.schedulerService.interWorkers.pipe(takeUntil(this.destroyed$)).subscribe(
      data => {
        this.interWorkers = data;

    const e = new EventStore({
      modelClass: InterventionWorkerSchedulerGpModel as any,
      data: this.interWorkers
    });

    const assig: any[] = [];
    this.interWorkers.forEach(ap => {
      ap.resourceIds.forEach(r => {
        const a: any = {
          resourceId: r,
          eventId: ap.id
        };

        assig.push(a);
      });
    });

    this.schedu.assignments = assig;
    this.schedu.eventStore = e;

  }
);

Re: [ANGULAR] Error when drag and drop event

Posted: Tue Aug 16, 2022 1:19 pm
by nico-priv

Here is a test case
[Removed by moderator. Please never post licensed Bryntum source code in open sources]


Re: [ANGULAR] Error when drag and drop event

Posted: Wed Aug 17, 2022 8:10 am
by tasnim

I cannot reproduce it in the test case that you provided. Could you please provide a test where I can reproduce the issue?


Re: [ANGULAR] Error when drag and drop event

Posted: Wed Aug 17, 2022 8:17 am
by nico-priv

Hello, i tried the test case and i have an error.
Try several times to drag and drop one of the events already created.

scheduler drag error.png
scheduler drag error.png (111.19 KiB) Viewed 291 times

Re: [ANGULAR] Error when drag and drop event

Posted: Fri Aug 19, 2022 11:06 am
by alex.l

This happened because of the way you set data into the scheduler.

First of all we highly recommend to use wrappers for work with frameworks. Please see https://bryntum.com/docs/scheduler/guide/Scheduler/quick-start/angular
https://bryntum.com/docs/scheduler/guide/Scheduler/integration/angular/guide

Second, you set eventStore class after scheduler initialized which is not necessary in your case and looks weird. If you want to work with inline data, please see https://bryntum.com/docs/scheduler/guide/Scheduler/integration/angular/data-binding

And the main problem is that when you replace a full eventStore instance with already created records after assignments data, it causes this problem. Basically, it's race condition because of such approach. Assignments check if any events available with id defined and set a link with assigned resource to event record. But in your case events are not there at the moment and more than that it won't happen after you set events as well, because you replaced full eventStore.

In 2 words, try to set assignments data after eventStore replacement.


  this.scheduler.eventStore = e;
  this.scheduler.assignments = assig;

But I highly recommend to read our guides and update your code to not have problems in the future :)
Good luck!


Re: [ANGULAR] Error when drag and drop event

Posted: Mon Aug 22, 2022 8:49 am
by nico-priv

Thank :D