Discuss anything related to web development but no technical support questions


Post by jaymadison »

Does anyone know if it is possible to drag events from 2 different resources and drop them onto another single resource?

Take this example for instance (https://www.bryntum.com/examples/schedul ... lugin.html). If you select Mike 13:00-16:00 and Kate 9:00-13:00 can you drag these down to Dave so that when dropped both show for Dave?

If I try this on the example above, only one will make it to Dave. The other is a row off.

Post by Maxim Gorkovsky »

Hello.
Yes, this could be done fairly easy. Take a look at this thread, it contain code snippet that you can adapt to your needs. That method should be a listener of 'beforeeventdropfinalize' event

Post by jaymadison »

I see how this gets the new resource record for each event dragged. However, I want both events to be dropped onto the same resource. I get visually as a drag the spacing stays as is, but after I drop on a resource I would like both to show on that resource.

Currently after the drop, one event appears on the resource I dropped but the other is a few indexes off.

I tried to loop through all draggedRecords and setResource to the dragContext.newResource, but this has no effect.

I am doing all this within the "beforeeventdropfinalize" event.
Ext.Array.forEach(dragContext.draggedRecords, function (item) {
    item.setResource(dragContext.newResource);
});

Post by Maxim Gorkovsky »

Post all contents of your method, please

Post by jaymadison »

    schBuildScheduleViewport_beforeeventdropfinalize: function (sch, dragContext, e) {
        var targetResourceRecord = dragContext.newResource.raw;

        if (targetResourceRecord.rec_type !== "booking") {
            Ext.toast({
                html: "You can't drop bookings here.",
                closable: false,
                align: 't',
                slideInDuration: 400,
                minWidth: 400
            });
            dragContext.finalize(false);
            return false;
        } else {
            var changingResource = targetResourceRecord.element_id !== dragContext.resourceRecord.raw.element_id;
            if (changingResource) {
                Ext.Array.forEach(dragContext.draggedRecords, function (item) {
                    item.setResource(dragContext.newResource);
                });
            }
            dragContext.finalize(true);
            return false;
        }
    }

Post by Maxim Gorkovsky »

You should call 'finalize' before making your custom changes

Post by jaymadison »

Worked great, thanks!

Post Reply