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

What would cause a certain data object to not be sortable, while others are?

3 Answers 57 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Devlin Baker
Top achievements
Rank 1
Devlin Baker asked on 12 Jun 2011, 07:35 PM
I have a RadGridView that can be loaded with various different business objects, primarily containing double, int and string members for editing. The columns of some of these objects can be sorted, but on others, no column in the grid will sort. This is despite setting CanUserSortColumns and IsSortable to true. Strangely, grouping and filtering works on these objects. I have removed any custom CellTemplates in case that was the issue.

To figure this out, I attempted to listen to the Sorting event on the grid, but it never fires. Any hint as to what direction I should look? How does the RadGrid determine whether data can be sorted, aside from the xaml input?

3 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 13 Jun 2011, 07:17 AM
Hello Devlin Baker,

Generally, sorting should be enabled for source collections that implement either IComparable Interface or IEquatable Interface. In this case, however, all columns should be sortable. Do you experience this behavior only for some column in one RadGridView or for columns in separate instances of RadGridView ? May you share a bit more information about the way your grid(s) and the corresponding columns are defined ? What is the type of your source collection ?

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
Devlin Baker
Top achievements
Rank 1
answered on 13 Jun 2011, 05:03 PM
The issue arises with all columns of the grid when it occurs, but only happens with certain data objects. Also, I noted that the InvertGroupSortDirectionRequested event doesn't fire in this instance, making it difficult to define a custom sorting routine as a work around.

While initially it was quite complex, I have simplified the grid down to bare-bones in an attempt to find the issue.

<telerik:RadGridView ItemsSource="{Binding Paths}" AutoGenerateColumns="True" CanUserSortColumns="True"/>

"Paths" is in this instance an IList<Path> in the viewmodel, where path is a database object containing a description and a few numerical double values, as well as an IList<Segment> of segment objects. However, the data is only converted to an IList after being passed over a service separate from the shell application, and it stored differently in the data service. Given what you said about requiring implementation of IComparable or IEquatable, I suspect the data is not properly implementing these interfaces upon conversion. Why this varies between data objects is troubling, but it seems the most logical answer.



0
Maya
Telerik team
answered on 16 Jun 2011, 02:13 PM
Hi Devlin Baker,

Unfortunately, without any additional information I cannot suggest any further. Still, if you want to be able to sort, you have to keep your source collection implementing IComparable or IEquatable Interface.
Let me know if I could be of any further assistance.

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