
Hello,
I have a radscheduler on my page. It is currently ordered by default, by start time of the appointment. I want the appointments to be sorted by a custom property "CompanyLocation". I followed this post but could not get the correct result. The post is this
http://www.telerik.com/community/forums/aspnet-ajax/scheduler/how-can-i-change-the-display-order-of-the-radscheduler-appointment-in-monthview.aspx
At the bottom you will see my comment there. I was wondering if that thread is closed. Basically I load a datatable from my stored procedure with 6 columns ID,Subject,Start,end,CompanyLocation. In mark up I have
CustomAttributeNames="CompanyLocation" EnableCustomAttributeEditing="true"
In my pageload I call a BindData function that populates and fills the datatable which I bind
radScheduler.DataSource = dt
radScheduler.DataBind()
Protected Overrides Sub OnInit(e As EventArgs)
MyBase.OnInit(e)
radScheduler.AppointmentComparer = New CustomAppointmentComparer("CompanyLocation", SortDirection.Descending)
End Sub
My CustomAppointmentComparer class is like this:
Class CustomAppointmentComparer
Implements IComparer
 
Private m_strField As String
Private _sortDirection As SortDirection
Sub New(strField As String, sortDirection As SortDirection)
m_strField = strField
_sortDirection = sortDirection
End Sub
Public Function Compare(first As Appointment, second As Appointment) As Integer
If first.Start < second.Start Then
Return -1
End If
If first.Start > second.Start Then
Return 1
End If
If first.[End] > second.[End] Then
Return -1
End If
Return [String].Compare(first.Attributes(m_strField), second.Attributes(m_strField))
End Function
Public Function Compare1(ByVal x As Object, ByVal y As Object) As Integer Implements System.Collections.IComparer.Compare
Dim apt1 As Appointment
Dim apt2 As Appointment
If GetType(Appointment).IsInstanceOfType(x) Then
apt1 = CType(x, Appointment)
Else
Throw New Exception("Casting failed...")
End If
If GetType(Appointment).IsInstanceOfType(y) Then
apt2 = CType(y, Appointment)
Else
Throw New Exception("Casting failed...")
End If
Select Case _sortDirection
Case SortDirection.Ascending
Return x.GetType.GetProperty(m_strField).GetValue(x, Nothing) < y.GetType.GetProperty(m_strField).GetValue(y, Nothing)
Case Else 'SortDirection.Descending
Return x.GetType.GetProperty(m_strField).GetValue(x, Nothing) > y.GetType.GetProperty(m_strField).GetValue(y, Nothing)
End Select
End Function
End Class
So what is that I am doing wrong?

01.<telerik:RadGrid ID="grdCustomers" runat="server" GridLines="None"02. AllowSorting="true" OnItemCreated="grdCustomers_ItemCreated" OnSortCommand="grdCustomers_SortCommand"03. OnItemCommand="grdCustomers_ItemCommand"04. OnNeedDataSource="grdCustomers_NeedDataSource"> 05. <HeaderContextMenu>06. <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>07. </HeaderContextMenu>08. <ClientSettings>09. <Resizing AllowColumnResize="true" EnableRealTimeResize="true" ResizeGridOnColumnResize="true" ClipCellContentOnResize="false" />10. </ClientSettings>11. <MasterTableView AutoGenerateColumns="False" HierarchyLoadMode="ServerOnDemand" DataKeyNames="CustomerID" TableLayout="Auto"12. Name="Master">13. <RowIndicatorColumn>14. <HeaderStyle Width="20px"></HeaderStyle>15. </RowIndicatorColumn>16. <ExpandCollapseColumn>17. <HeaderStyle Width="20px"></HeaderStyle>18. </ExpandCollapseColumn>19. <AlternatingItemStyle CssClass="config_alternating_item" />20. <Columns>21. <telerik:GridTemplateColumn UniqueName="IDColumn" HeaderText="ID" SortExpression="CustomerID">22. <ItemTemplate>23. <asp:LinkButton ID="lbtnID" runat="server"24. CommandName="EditCustomer"25. CommandArgument='<%# ourObject.CustomerID %>' />26. <br />27. <asp:Literal ID="ltCreatedOn" runat="server" />28. </ItemTemplate>29. </telerik:GridTemplateColumn>30. <telerik:GridTemplateColumn HeaderText="Name" UniqueName="NameColumn" SortExpression="Name">31. <ItemTemplate>32. <asp:LinkButton ID="lbtnName" runat="server"33. CommandName="EditCustomer"34. CommandArgument='<%# CustomerID %>'/>35. </ItemTemplate>36. </telerik:GridTemplateColumn>37. </Columns>38. </MasterTableView>39. <FilterMenu>40. <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>41. </FilterMenu>42.</telerik:RadGrid>01.<div id="pregenID" class="RadGrid RadGrid_Default" tabindex="0">02. <table class="rgMasterTable" border="0" id="pregenID" style="width:100%;table-layout:auto;empty-cells:show;">03. <colgroup>04. <col>05. <col>06. </colgroup>07. <thead>08. <tr>09. <th scope="col" class="rgHeader" title="">10. <a title="Click here to sort" href="postback">ID</a>11. </th>12. <th scope="col" class="rgHeader" title="">13. <a title="Click here to sort" href="postback">Name</a>14. </th>15. </tr>16. </thead>17. <tbody>18. <tr class="rgRow" id="pregenID">19. <td>20. <a id="col1">cust id</a>21. <br>22. 9/9/201423. </td>24. <td>25. <a id="col2">cust name</a>26. </td>27. </tr>28. <tr class="rgAltRow config_alternating_item" id="pregenID">29. <td>30. <a id="col1">cust2 id</a>31. <br>32. 9/6/201433. </td>34. <td>35. <a id="col2">cust2 name</a>36. </td>37. </tr>38. </tbody>39. </table>40.</div>01.<div id="pregenID" class="RadGrid RadGrid_Default">02. <a id="pregenID" href="postback">cust id</a>03. <br>04. 9/9/201405.</div>06.<td>07. <a id="pregenID" href="postback">cust name</a>08.</td>09.</tr>10.<tr class="rgAltRow config_alternating_item" id="pregenID">11. <td>12. <a id="pregenID" href="postback">cust2 id</a>13. <br>14. 9/6/201415. </td>16. <td>17. <a id="pregenID" href="postback">Admin User</a>18. </td>19.</tr><telerik:RadMenu ID="rmMenu" runat="server" EnableImagePreloading="true" EnableEmbeddedSkins="false" BorderColor="Black" BorderStyle="None" BorderWidth="0px" Skin="COPMenu" BackColor="Transparent" ExpandAnimation-Type="None"> <Items> <telerik:RadMenuItem ID="riTrans" runat="server" Text="Communication"></telerik:RadMenuItem> <telerik:RadMenuItem ID="riGen" runat="server" Text="Appointment Book"></telerik:RadMenuItem> </Items></telerik:RadMenu>