Moving an event on itself with IsSlotAvailable

Hi,

I have a feature that prohibits the user from dragging events over slots already taken.
But when I want to move an event on itself (for example, it's a four-hour event and I want to move it half an hour later), the slot is already considered unavailable .
Is there a way to get the Id of the event in the slot to compare it to the moved event? 
Or maybe there is another way to avoid this situation?

Can you help me?
This is my function:


  public onDragStop(argsDragEventArgs): void {
    let cellDataCellClickEventArgs = this.driverSchedule.getCellDetails(
      args.target,
    );
    let resourceDetailsResourceDetails;

    if (cellData !== undefined) {
      resourceDetails = this.driverSchedule.getResourcesByIndex(
        cellData.groupIndex,
      );
      let eventData: { [keystring]: Object } = {
        StartTime: cellData.startTime,
        EndTime: cellData.endTime,
      };

      const groupIndexnumber = cellData.groupIndex;

      if (
        !this.driverSchedule.isSlotAvailable(
          eventData.StartTime as Date,
          eventData.EndTime as Date,
          groupIndex as number,
        )
      ) {
        args.cancel = true;
        console.log('Slot is unavailable');
      }
    }
  }

1 Reply 1 reply marked as answer

RV Ravikumar Venkatesan Syncfusion Team June 24, 2020 01:45 PM UTC

Hi Anais, 

Greetings from Syncfusion support. 

We have validated your reported “Moving an event on itself with IsSlotAvailable” query at our end. We have achieved your requirement with the help of the below code. We have prepared a sample for your reference and it can be available below. 

[app.component.html] 
  onDragStop(args: DragEventArgs): void { 
    if (args.target.classList.contains('e-work-cells')) { 
      let groupIndex: number = +(args.target as any).getAttribute('data-group-index'); 
      if (!this.scheduleObj.isSlotAvailable(args.data.StartTime as Date, args.data.EndTime as Date, groupIndex as number)) { 
        args.cancel = true; 
        console.log('Slot is unavailable'); 
      } 
    } 
  } 


Kindly try the above sample and get back to us if you would require further assistance. 

Regards, 
Ravikumar Venkatesan 


Marked as answer
Loader.
Up arrow icon