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

How to set appointment in alphabatic order in schedular

4 Answers 67 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Samir Patel
Top achievements
Rank 1
Samir Patel asked on 11 Sep 2009, 03:18 PM
I have more then 15 appoint ment for one date , and i want to set that alphabatical order... how can i set..?


REgards
Samir

4 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 15 Sep 2009, 01:16 PM
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.
0
Samir Patel
Top achievements
Rank 1
answered on 15 Sep 2009, 06:59 PM
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
0
Allen
Top achievements
Rank 1
answered on 18 May 2012, 02:45 PM
Do you have VB code for this?
0
Allen
Top achievements
Rank 1
answered on 18 May 2012, 04:47 PM
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

 

 

 

Tags
Scheduler
Asked by
Samir Patel
Top achievements
Rank 1
Answers by
Peter
Telerik team
Samir Patel
Top achievements
Rank 1
Allen
Top achievements
Rank 1
Share this question
or