Custom sort behaviour

7 posts, 1 answers
  1. Will
    Will avatar
    27 posts
    Member since:
    Jun 2008

    Posted 03 Jul 2008 Link to this post

    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
  2. Hristo Deshev
    Admin
    Hristo Deshev avatar
    559 posts

    Posted 07 Jul 2008 Link to this post

    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
  3. Will
    Will avatar
    27 posts
    Member since:
    Jun 2008

    Posted 07 Jul 2008 Link to this post

    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
  4. Hristo Deshev
    Admin
    Hristo Deshev avatar
    559 posts

    Posted 08 Jul 2008 Link to this post

    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
  5. Will
    Will avatar
    27 posts
    Member since:
    Jun 2008

    Posted 08 Jul 2008 Link to this post

    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
  6. Answer
    Hristo Deshev
    Admin
    Hristo Deshev avatar
    559 posts

    Posted 09 Jul 2008 Link to this post

    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
  7. Will
    Will avatar
    27 posts
    Member since:
    Jun 2008

    Posted 09 Jul 2008 Link to this post

    Thanks Hristo - looks to be a good solution. Looking forward to the final release!

    Will
Back to Top