Hello and thank you for taking your time to help me :
When the user is moving the appointment or resizing them, I'm displaying a javascript "confirm" that should impact the appointment to be updated
If the confirm returns true, I want to add a custom attribute to the appointment, else, I do nothing
But it seems that client-side modifications do not affect the appointment that is received on server-side
Here is my function for Moving (Resizing is pretty much the same) :
function
ClientAppointmentMoveEndHandler(sender, args) {
var
app = args.get_appointment();
var
confirmMessage =
"Bla bla bla."
+
"\nWant to notify?"
;
if
(confirm(confirmMessage)) {
app.get_attributes().setAttribute(
"notifyModif"
,
"true"
);
}
}
Also tried to modify the subject in case it would be related to the attributes, but didn't work either
My server-side event handler is :
protected
void
RadScheduler1_AppointmentUpdate(
object
sender, AppointmentUpdateEventArgs e)
{
AppointmentInfo ai = FindById(e.ModifiedAppointment.ID);
ai.CopyInfo(e.ModifiedAppointment);
ai.ApplyChangesToDB();
}
I'm using the debugger to see the state of e.ModifiedAppointment when reaching the first line of the handler, and neither the subject nor the Attributes collection are changed (though they should have been by my Javascript code)
How can I achieve that?
Also, if your solution could use a radconfirm instead of a confirm that would be awesome !
Thank you for your help
6 Answers, 1 is accepted
I would like to clarify that when RadScheduler is populated using server-side binding only the appointment required fields could be set from the client-side: start time, end time and subject. Any additional fields such as description and custom attributes could be set from the client-side only with web service binding.
However a possible workaround in this case could be using hidden fields for any custom attributes. Since the hidden fields have runat="server" set they are available server-side so you can read the appointment custom attribute value:
<
asp:HiddenField
ID
=
"customAttribute"
runat
=
"server"
/>
function
OnClientAppointmentMoveEnd(sender, args) {
var
appointment = args.get_appointment();
var
attributes = appointment.get_attributes();
$get(
"customAttribute"
).value =
"true"
;
}
protected
void
RadScheduler1_AppointmentUpdate(
object
sender, AppointmentUpdateEventArgs e)
{
string
value = customAttribute.Value;
e.ModifiedAppointment.Attributes.Add(
"notifyModif"
, value);
}
As for your second question I would suggest reviewing our RadScheduler client-side API demo that implements very similar scenario - when user tries to move an appointment that will overlap an already existing appointment, a radconfirm window pops up. Based on the selected option the appointment will be moved to the new time slot or moving will be canceled.
Regards,
Anton
Telerik by Progress
Thank you for the provided solution.
It worked fine but there's one issue :
I following your client-side API demo and upon reaching the "args.set_cancel(true);" line in the MoveEnd handler, the appointment moves back to it's initial start/end and loses the new info.
How do I avoid that?
Thank you
Addition to last post :
I re-read the provided script in the demo and noticed you had to reassign the start and end time after the set_cancel line. (Seems a bit weird to be honest)
So I did the same, and it's not working BUT the appointment goes back to its place until I press either yes or no on the radconfirm.
Here's the full handler so we understand each others
function
ClientAppointmentMoveEndHandler(sender, args) {
var
app = args.get_appointment();
// Calculate the duration of the appointment
var
appointmentDuration = app.get_end() - app.get_start();
// The new start time is provided in the event arguments
var
newStartTime = args.get_newStartTime();
// Add the duration of the appointment to the new start time to get the new end time
var
newEndTime =
new
Date(newStartTime.getTime() + appointmentDuration);
var
confirmMessage =
"Un déplacement de rendez-vous a été détecté."
+
"\nSouhaitez-vous notifier le client de ce changement?"
;
args.set_cancel(
true
);
radconfirm(confirmMessage,
function
(arg) {
if
(arg) {
$get(
'<%=notify.ClientID%>'
).value =
"true"
;
}
app.set_start(newStartTime);
app.set_end(newEndTime);
sender.updateAppointment(app);
},
400,
100,
null
,
"Déplacement de rendez-vous détecté"
);
}
I updated the code in your radConfirm function and as you can see on the video, at my side after pressing 'Yes' on the confirm window, the appointment is moved and after pressing 'Cancel' - the appointment is stopped from moving.
Please find attached the sample website from the video.
Regards,
Anton
Telerik by Progress
Same thing happens to me and that's exactly the issue. When you release the appointment, it goes back to its previous place while the radconfirm appears.
What is expected is for the appointment to stay at the place it is dropped at while the radconfirm is showing up.
(Then goes back to previous place if updating is aborted through the cancel button obviously, but only in that case)
When using a radConfirm actually the thread maintaining the task is not stopped as when using the browsers confirm window. In the appointmentMoveEnd function args.set_cancel(true) is what causes the appointment to move to its initial position and if you confirm on the radConfirm its position is recalculated. You can consider this as limitation if you want to stay with the radConfirm window.
Regards,
Anton
Telerik by Progress