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

Sorting on Object columns

2 Answers 67 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Carl Rippon
Top achievements
Rank 1
Carl Rippon asked on 03 Aug 2010, 12:07 PM
Sorting on Object columns doesn't seem to work. To recreate the problem:
  • Paste the following code into the code behind of MainPage in a blank silverlight project
  • Run the application
  • Click on the header of the Name column (which is of type Object) - this does NOT work
  • Click on the header of the NameString column (which is of type String) - this does work

Is this a bug or am I missing something?

Partial Public Class MainPage
    Inherits UserControl
  
    Public Sub New()
        InitializeComponent()
  
        Dim RadGridView1 As New Telerik.Windows.Controls.RadGridView
        RadGridView1.AutoGenerateColumns = False
        RadGridView1.Columns.Add(New GridViewDataColumn With {.DataMemberBinding = New Binding("Name"), .Header = "Name"})
        RadGridView1.Columns.Add(New GridViewDataColumn With {.DataMemberBinding = New Binding("NameString"), .Header = "NameString"})
        RadGridView1.ItemsSource = GetListData()
        LayoutRoot.Children.Add(RadGridView1)
    End Sub
  
    Private Function GetListData() As List(Of Item)
        Dim build As New List(Of Item)
        build.Add(New Item With {.Name = "Tom", .NameString = "Tom"})
        build.Add(New Item With {.Name = "Fred", .NameString = "Fred"})
        build.Add(New Item With {.Name = "Bill", .NameString = "Bill"})
        Return build
    End Function
  
    Public Class Item
        Public Property Name As Object
        Public Property NameString As String
    End Class
  
End Class

2 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 03 Aug 2010, 12:49 PM
Hi Carl Rippon,

 
That is the expected behavior as in order to enable sorting, the source for the column should implement either IComparable Interface or IEquatable Interface.


Kind regards,
Maya
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Carl Rippon
Top achievements
Rank 1
answered on 03 Aug 2010, 01:40 PM
Thanks, that makes sense!
Tags
GridView
Asked by
Carl Rippon
Top achievements
Rank 1
Answers by
Maya
Telerik team
Carl Rippon
Top achievements
Rank 1
Share this question
or