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

Custom sort behaviour

6 Answers 154 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Will
Top achievements
Rank 1
Will asked on 03 Jul 2008, 12:43 PM
The current SortingRequested event only fires when the field being sorted implenents IComparable (seemly making the custom sort behaviour irrelevant?). In order to work around this (we want to sort at the database) I tried subclassing GridViewDataColumn so I could override CanSort() to remove this constraint. However, CanSort is not a virtual method so this doesn't work.

Do you have any suggestions to work around this behaviour? Adding a dummy IComparable implmentation to all of our entities is not really a good solution for us.

Many thanks,

Will Holley

6 Answers, 1 is accepted

Sort by
0
Hristo Deshev
Telerik team
answered on 07 Jul 2008, 11:31 AM
Hello Will,

Thanks for reporting this. Unfortunately, it turns out that there is no good way to work around that issue for Beta 2. I've been thinking about the best way to tackle the problem and I found a good solution in our ASP.NET grid. We can add a public RadGridView.IsCustomSortingAllowed property that will tell us if the RadGridView client code will do the sorting itself. This way our CanSort() logic can take advantage on the column data type if and only if the IsCustomSortingAllowed property is false. What do you think?

By the way, I have updated your Telerik points.

Sincerely yours,
Hristo Deshev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Will
Top achievements
Rank 1
answered on 07 Jul 2008, 11:47 AM
Hi Hristo,

I don't really know how other people are using this feature, but from our use case maybe you could assume that if the SortingRequested event is hooked then the user is handling it themselves?

Maybe 2 events are needed, one for intercepting when the grid runs its own sorting logic and one to run custom sorting logic?

Will
0
Hristo Deshev
Telerik team
answered on 08 Jul 2008, 03:41 PM
Hello Will,

I don't see the point of having two events for doing what is essentially the same thing: suppressing the default sort logic and doing your own thing instead. Detecting if the user has handled the event and then decide whether to enable custom sorting sounds nice, but there is one complication -- the event is a routed one and it can be handled at different levels in the visual tree.

Maybe we can turn the event into a regular CLR event exposed at the RadGridView control and make users handle it only there. In addition we may have to do our own bubbling and take care to raise that event from inner tables when we have hierarchy defined. Does losing the event routing feature make sense?

All the best,
Hristo Deshev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Will
Top achievements
Rank 1
answered on 08 Jul 2008, 03:53 PM
Y I think a normal CLR event would do, although having thought about it more I'm coming around to your original suggestion of just using a flag. Since one might want to implement custom sorting behaviour on specific columns, having a flag on FieldDescriptors / GridViewColumns to enable custom sort behaviour for that column as well as global flag also for the default seems like a flexible and simple solution.

Will
0
Accepted
Hristo Deshev
Telerik team
answered on 09 Jul 2008, 10:30 AM
Hi Will,

After a short discussion with the rest of the team members, we decided to go that route. We'll be adding an IsCustomSortingEnabled property to gridview columns. Setting it to true will trigger the SortingRequested event regardless of the column data type.

Kind regards,
Hristo Deshev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Will
Top achievements
Rank 1
answered on 09 Jul 2008, 10:53 AM
Thanks Hristo - looks to be a good solution. Looking forward to the final release!

Will
Tags
General Discussions
Asked by
Will
Top achievements
Rank 1
Answers by
Hristo Deshev
Telerik team
Will
Top achievements
Rank 1
Share this question
or