Our pure JavaScript Scheduler component


Post by ashokap »

I am working on a project in which the startTime and endtime should be same when moved from one resource to another resource

    scheduler.on({
        eventDrop: ({source, eventRecords, context}) => {
      
            if (context.unAssignedTask) {
    //Data from another schedule
                let resources = unassigned_scheduler.resources;
                for (let resource of resources) {
                    if (resource.id === context.record.id) {
                        resource.remove()
                        break;
                    }
                }
            }else{
                let eventRecord=eventRecords[0];
                eventRecord.startDate=eventRecord.originalData.startDate;
                eventRecord.endDate=eventRecord.originalData.endDate;
            }
        },
        afterEventDrop:({source,eventRecords,context}) => {
            if (context.unAssignedTask){
                 let eventRecord=eventRecords[0];

                 let events=scheduler.events;
                 for (let event of events){
                     if (event.data.dragId===context.record.id) {
                         event.startDate=eventRecord.originalData.startDate;
                         event.endDate=eventRecord.originalData.endDate;
                     }
                 }
            }
        }

    });
]

As you can see on the eventDrop options I am setting startdate and enddate of eventrecord to originaleventrecord. This works fine when I move event withing one scheduler but it doesn't work while move the data between two scheduler . I want to set the startdate and endate and move the event to proper position but it stays in the position where I drop it. Currently I have workaround for this but is there more efficient way of doing this?

Post by mats »

Please modify our drag-between-schedulers demo and upload it here so we can run and see what you see (include all steps necessary too).

Post by ashokap »

I have attached the file . See this line of code
scheduler1.on({
    eventDrop: ({source, eventRecords, context}) => {
            let eventRecord = eventRecords[0];
            eventRecord.startDate = eventRecord.originalData.startDate;
            eventRecord.endDate = eventRecord.originalData.endDate;
    }
});
It is used so that when the data is moved from one resource to another . The start and endtime are same . It works when you use on the same scheduler but when you move from another scheduler it doesn't work
Attachments
drag-between-schedulers.zip
(154.78 KiB) Downloaded 152 times

Post by mats »

Looks like a bug yes, ticket opened here: https://app.assembla.com/spaces/bryntum ... rs/details#

Post Reply