This is a migrated thread and some comments may be shown as answers.

Client side moving of appointments results in mixed up resources

1 Answer 52 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Datamex
Top achievements
Rank 2
Datamex asked on 03 Nov 2009, 11:00 AM
Hi,

I'm using version 2009.2.1007.35 of the radcontrols at the moment. I have a RadScheduler component in my page.
Moving an appointment results in a piece of javascript running, which uses a call to a webmethod to see if the appointment can be moved. Because I don't want the appointment to "jump around on the screen", I don't cancel the event.
When the call to the webmethod returns, it might return a value indicating that the move was invalid or not allowed. In that case, I have to move the appointment back to its original time (begin and end), but also to its original resource.

To do this I have this piece of code:
var curResource = telerikAppointment.get_resources().getResourceByType("Employee"); 
curResource.set_key(oldEmployeeID); 
curResource.set_text(oldEmployeeName); 
telerikAppointment.set_start(oldStartTime); 
telerikAppointment.set_end(oldEndTime); 
radScheduler.updateAppointment(globalData.telerikAppointment, false); 

But now the problem:

When this code has run, the resource in the scheduler itself is also overwritten. I will try to explain this: Say I move an appointment from resource 1 to 2, but it is invalid, so I move it back to 1 using the code as above. Afterwards, everything I move to 2 will have e.get_targetSlot().get_resource().get_key() = 1 in a handler for the OnClientAppointmentMoveEnd event, while that should be 2. So it seems the set_key and set_text on the resource of the appointment has also overwritten the resource of the scheduler itself.

This might be intended (probable the resources of the appointment ARE the resources known in the Scheduler), so I'm not sure if this is a bug. But in any case, I'm looking for a way to move an appointment from one resource to another in clientside javascript, without messing things up

Any help would be greatly appreciated!

1 Answer, 1 is accepted

Sort by
0
Datamex
Top achievements
Rank 2
answered on 03 Nov 2009, 11:31 AM
I already solved it, but I'll post it here as it may help others:

I have changed the code as follows:
var curResource = telerikAppointment.get_resources().getResourceByType("Employee"); 
telerikAppointment.get_resources().remove(curResource); 
telerikAppointment.get_resources().add(oldResource); 
 
telerikAppointment.set_start(oldStartTime);  
telerikAppointment.set_end(oldEndTime);  
radScheduler.updateAppointment(globalData.telerikAppointment, false);  
The main difference is the fact that I do no longer remember the old key and text, but the whole resource. I remove the reference to the resource and replace it with a reference to the old resource. Altering a resource as I did before is (I see now) a no-no, as I'm altering a resource object itself, which is used in different collections (other appointments and the resources of the scheduler itself).
Tags
Scheduler
Asked by
Datamex
Top achievements
Rank 2
Answers by
Datamex
Top achievements
Rank 2
Share this question
or