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

Sorting a column with data of type object

5 Answers 118 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Uli
Top achievements
Rank 1
Uli asked on 26 Aug 2010, 04:09 PM
Hi,

I'm using a custom sort algorithm. One of my columns is bound to a property of type object. If I click on the header of this column the SortingStateChanged event is not fired. If I change the type of the property to string, the event is fired.

Is there a way to sort columns bound to a property of type object?

Regards Uli

5 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 26 Aug 2010, 04:19 PM
Hello Uli,

You may take a look at this forum thread as a reference. 

Greetings,
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
Uli
Top achievements
Rank 1
answered on 26 Aug 2010, 04:26 PM
Hi Maya,

the restriction that the source of the column should implement IComparable Interface or IEquatable Interface is only valid if I don't use an custom sort algorithm. I just want to configure the columns used for sorting with RadGridView functionality.

Regards Uli
0
Jason
Top achievements
Rank 1
answered on 26 Aug 2010, 06:08 PM
Maybe I'm misunderstanding Uli, but it seems like since you are implementing a custom sort algorithm, that it should be implemented as part of the CompareTo method required by the IComparable interface contract. 
0
Uli
Top achievements
Rank 1
answered on 27 Aug 2010, 08:47 AM
In my application I have a column that contains bool, float, int and string values. I' using DataTemplateSelectors to display and edit these values. The column should be sorted. The custom sort algorithm I have implemented sorts them first by their type and then according to their specific natural sorting. It does not rely on IComparable.

The type of the property the column is bound to must be object because this is the only common base class of the bool, float, int and string.

If I use object as type of the data I'm not able to activate the sorting by clicking the column header.

Regards Uli
0
Maya
Telerik team
answered on 01 Sep 2010, 07:22 AM
Hello Uli,

You may try to set the property of the column IsCustomSortingEnabled to "True". Afterwards you will be able to handle the Sorting event of the grid, cancel it and implement your own custom logic.
 

Greetings,
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
Tags
GridView
Asked by
Uli
Top achievements
Rank 1
Answers by
Maya
Telerik team
Uli
Top achievements
Rank 1
Jason
Top achievements
Rank 1
Share this question
or