ASPxClientScheduler.AppointmentDeleting Event
Client-side event that fires before an appointment is deleted.
Declaration
AppointmentDeleting: ASPxClientEvent<ASPxClientAppointmentDeletingEventHandler<ASPxClientScheduler>>
Event Data
Property |
Description |
appointmentIds |
Gets client IDs of the appointments to be removed.
|
cancel |
Specifies whether to cancel the related action (for example, row edit, export).
|
This client-side event enables you to decide whether a particular appointment should be deleted. You can analyze the ASPxClientAppointmentDeletingEventArgs.appointmentIds object, containing client appointment IDs. Use the ASPxClientScheduler.GetAppointmentById property to get more information on a certain appointment. If its deletion is not what you want, set the ASPxClientCancelEventArgs.cancel parameter to true
.
Example
The following example illustrates how to use the ASPxClientScheduler.AppointmentDeleting
event.
protected void ASPxScheduler1_InitClientAppointment(object sender, InitClientAppointmentEventArgs args) {
// Custom Field values (additional information about appointments) are passed to the client appointments so that these fields values can be analyzed in JS
args.Properties.Add("cpCompleted", args.Appointment.CustomFields["LessonCompleted"]);
args.Properties.Add("cpCustomRecurringFlag", args.Appointment.CustomFields["CustomRecurringFlag"]);
args.Properties.Add("cpCustomRecurringID", args.Appointment.CustomFields["CustomRecurringID"]);
}
function OnAppointmentDeleting(s, e) {
var currentAppointment;
if ((typeof e.appointmentIds[0]) == "object")
currentAppointment = e.appointmentIds[0]
else
currentAppointment = s.GetAppointmentById(e.appointmentIds[0]);
if (currentAppointment.cpCompleted) {
// disable deleting appointments with the "Completed" status
alert("You cannot delete appointments with 'Completed' status");
e.cancel = true;
}
else if (currentAppointment.cpCustomRecurringFlag) {
// if an appointment belongs to a custom "recurring" series, a confirmation to delete a current appointment or an entire series is shown
// an end-user's choice is stored as a hidden field value
hfClientDeleteMode.Set("DeleteMode", confirm("Do you want to delete all occurrences in this recurring series?"));
}
else {
// a regulal confirmation before deleting an appointment
e.cancel = !confirm("Do you really want to delete this appointment?");
}
}
<Appointments AutoRetrieveId="True" ResourceSharing="false">
...
<CustomFieldMappings>
<dxwschs:ASPxAppointmentCustomFieldMapping Member="Completed" Name="LessonCompleted" ValueType="Boolean" />
<dxwschs:ASPxAppointmentCustomFieldMapping Member="CustomIsRecurring" Name="CustomRecurringFlag" ValueType="Boolean" />
<dxwschs:ASPxAppointmentCustomFieldMapping Member="CustomRecurringID" Name="CustomRecurringID" ValueType="String" />
<dxwschs:ASPxAppointmentCustomFieldMapping Member="CreatedBy" Name="ApptCreatedBy" ValueType="String" />
<dxwschs:ASPxAppointmentCustomFieldMapping Member="ModifiedBy" Name="ApptModifiedBy" ValueType="String" />
<dxwschs:ASPxAppointmentCustomFieldMapping Member="CreatedDate" Name="ApptCreatedDate" ValueType="DateTime" />
<dxwschs:ASPxAppointmentCustomFieldMapping Member="ModifiedDate" Name="ApptModifiedDate" ValueType="DateTime" />
</CustomFieldMappings>
</Appointments>
...
<dx:ASPxHiddenField runat="server" ID="hfDeleteMode" ClientInstanceName="hfClientDeleteMode"></dx:ASPxHiddenField>
<dx:ASPxHiddenField runat="server" ID="hfCurrentUser" ClientInstanceName="hfClientCurrentUser">
<ClientSideEvents Init="OnHFInit" />
</dx:ASPxHiddenField>
See Also