How to set appointment in alphabatic order in schedular

5 posts, 0 answers
  1. Samir Patel
    Samir Patel avatar
    54 posts
    Member since:
    Jul 2009

    Posted 11 Sep 2009 Link to this post

    I have more then 15 appoint ment for one date , and i want to set that alphabatical order... how can i set..?


    REgards
    Samir
  2. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 15 Sep 2009 Link to this post

    Hello Samir,

    Yes, this can be done using the AppointmentComparer property of RadScheduler. Here is how:

    class CustomAppointmentComparer : IComparer<Appointment>  
    {  
        public int Compare(Appointment first, Appointment second)  
        {  
            if (first == null || second == null)  
            {  
                throw new InvalidOperationException("Can't compare null object(s).");  
            }  
     
            if (String.Compare(first.Subject, second.Subject) < 0)  
            {  
                return -1;  
            }  
     
            if (String.Compare(first.Subject, second.Subject) > 0)  
            {  
                return 1;  
            }        
     
            return 0;  
        }  
    }  
    public partial class _Default : System.Web.UI.Page   
    {    
        protected void Page_Init(object sender, EventArgs e)  
        {  
            RadScheduler1.AppointmentComparer = new CustomAppointmentComparer();   
           
        } 


    Regards,
    Peter
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Samir Patel
    Samir Patel avatar
    54 posts
    Member since:
    Jul 2009

    Posted 15 Sep 2009 Link to this post

    The code is working to set the appoint ment in alphabatic order, but now on adding new appointment to the other date.. the gap between two appoint ment for the previous date is increased, and due to this the schedaulr size is also increased....

    If i remove the code which you sent for alphabatic order , then the size is fixed and its workign fine...but then appointment is not in alphabatic order..??

    Help me...

    Regards
    Samir
  4. Allen
    Allen avatar
    111 posts
    Member since:
    Apr 2012

    Posted 18 May 2012 Link to this post

    Do you have VB code for this?
  5. Allen
    Allen avatar
    111 posts
    Member since:
    Apr 2012

    Posted 18 May 2012 Link to this post

    I try to write in in VB.NEt, but it give me error on " System.Collections.Generic.IComparer(Of Telerik.Web.UI.Appointment)":
    Here is the entire script:

    Imports Telerik.Web.UI
    Imports Microsoft.VisualBasic
    Imports System.Collections.Generic

    Partial Class _Default
        Inherits System.Web.UI.Page
        Class CustomAppointmentComparer
            Implements System.Collections.Generic.IComparer(Of Telerik.Web.UI.Appointment)

            Function Compare(first As Appointment, second As Appointment) As Integer

                If first Is Nothing OrElse second Is Nothing Then

                    Throw New InvalidOperationException("Can't compare null object(s).")
                End If

                If [String].Compare(first.Subject, second.Subject) < 0 Then

                    Return -1
                End If

                If [String].Compare(first.Subject, second.Subject) > 0 Then

                    Return 1
                End If

                Return 0

            End Function

        End Class
        Protected Sub Page_Init(sender As Object, e As EventArgs)

            RadScheduler2.AppointmentComparer = New CustomAppointmentComparer()

        End Sub
        Protected Sub RadScheduler1_AppointmentDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.SchedulerEventArgs) Handles RadScheduler2.AppointmentDataBound
            e.Appointment.CssClass = "MyCustomAppointmentStyle"
            If e.Appointment.Subject = "Availability" Then
                e.Appointment.CssClass = "•rsCategoryYellow"
            Else
                e.Appointment.CssClass = "rsCategoryGreen"
            End If
            ''e.Appointment.
        End Sub

        Protected Sub RadScheduler2_FormCreated(ByVal sender As Object, ByVal e As SchedulerFormCreatedEventArgs) Handles RadScheduler2.FormCreated

     

            If (e.Container.Mode = SchedulerFormMode.AdvancedEdit) OrElse (e.Container.Mode = SchedulerFormMode.AdvancedInsert) Then
                Dim allDayCheckbox As CheckBox = DirectCast(e.Container.FindControl("AllDayEvent"), CheckBox)
                allDayCheckbox.Style.Add("visibility", "hidden")
                Dim attrAnnotationsTextbox As RadTextBox = DirectCast(e.Container.FindControl("Subject"), RadTextBox)
                attrAnnotationsTextbox.Label = "Type"
                attrAnnotationsTextbox.Enabled = False
                Dim startPicker As RadTimePicker = DirectCast(e.Container.FindControl("StartTime"), RadTimePicker)
                startPicker.TimeView.StartTime = TimeSpan.FromHours(8)
                startPicker.TimeView.EndTime = TimeSpan.FromHours(24)
                startPicker.TimeView.DataList.DataSource = Nothing
                startPicker.TimeView.DataBind()
                Dim endPicker As RadTimePicker = DirectCast(e.Container.FindControl("EndTime"), RadTimePicker)
                endPicker.TimeView.StartTime = TimeSpan.FromHours(8)
                endPicker.TimeView.EndTime = TimeSpan.FromHours(24)
                endPicker.TimeView.DataList.DataSource = Nothing
                endPicker.TimeView.DataBind()
            End If
        End Sub

    End Class

     

     

     

Back to Top