The requested page is not available for the requested platform. You are viewing the content for Default platform.

ASPxClientScheduler.GetAppointmentById(id) Method

Client-side function that returns an appointment with the specified ID.

Declaration

GetAppointmentById(id: string): ASPxClientAppointment

Parameters

Name Type Description
id string

An appointment's identifier.

Returns

Type Description
ASPxClientAppointment

An ASPxClientAppointment object, representing an appointment on the client.

Remarks

This method obtains a client appointment by its id.

To get client appointment property values (including custom field values) handle the ASPxScheduler.InitClientAppointment event or use the ASPxClientScheduler.RefreshClientAppointmentProperties method.

The following example illustrates how to handle the ASPxClientScheduler.AppointmentsSelectionChanged client-side event and check if the selected appointment is in the past. To deselect these appointment(s), use the GetAppointmentById method and show a message for an end-user.


function SchedulerSelection(s, e) {
    var date = Date.now();
    var ids = e.appointmentIds;
    for (var i = 0; i < ids.length; i++) {
        var appointment = s.GetAppointmentById(ids[i]);
        if (appointment.GetEnd() - date < 0) {                    
            s.DeselectAppointmentById(ids[i]);
            alert("Appointment cannot be selected");
        }
    }
}

Examples

In this example, the ASPxClientScheduler.AppointmentResizing event is handled to disable resizing appointments with the "Completed" status. The ASPxScheduler.InitClientAppointment event is used to pass custom field values (that store additional information about appointments) to the client appointments.

<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>
protected void ASPxScheduler1_InitClientAppointment(object sender, InitClientAppointmentEventArgs args) {
    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 OnAppointmentResizing(s, e) {    
    var currentAppointment = s.GetAppointmentById(e.appointmentId);
    if (currentAppointment.cpCompleted) {
        e.allow = false;
    }
}
See Also