Custom Sort GroupDescriptors

8 posts, 0 answers
  1. Vivek
    Vivek avatar
    1 posts
    Member since:
    Mar 2012

    Posted 02 May 2012 Link to this post

    While SortDescriptors specify how to sort the items within the JumpList, is there a way i could specify how to sort the groups.
    For example:
    a
    1,2,3
    x
    4,5,6
    b
    1,4,5

    How can I specify I need my groups to be displayed in the order {a, x, b}?
  2. Deyan
    Admin
    Deyan avatar
    2041 posts

    Posted 04 May 2012 Link to this post

    Hello Vivek,

    Yes, there is a way to implement this scenario. One possible way would be to first sort the items by using the key that you will later group by. In this way the groups will be created in the order the items were sorted initially and you will get the desired result. When sorting, you will also need to implement the IComparable interface in your business objects and provide the proper comparison logic so that you make x<b.

    Let me know in case you have further questions or need assistance.

    Regards,
    Deyan
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft banner
  4. Eugene
    Eugene avatar
    7 posts
    Member since:
    May 2013

    Posted 28 Jan 2014 in reply to Deyan Link to this post

    Reviving an old post.

    So the item sorting solution would work if the items never move within groups. In my case, I actually have a case where the items may move from one group to another, and I need the groups sorted. How would I implement that?
  5. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 03 Feb 2014 Link to this post

    Hi Eugene,

    Your group descriptors should have a SortMode property. You can set it to make sure that your groups are always sorted in some order.

    Please write again if you have other questions.

    Regards,
    Victor
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peek previews directly from the developers working on the UI for Windows Phone, subscribe to the blog feed now.
  6. Eugene
    Eugene avatar
    7 posts
    Member since:
    May 2013

    Posted 03 Feb 2014 in reply to Victor Link to this post

    SortMode only allows Ascending or Descending, from what I can tell. Really, a GroupDescriptor should be derived from IComparable<GroupDescriptor>, and allow overriding of the Compare operator. That would be a more .NET way of structuring this API.

    But short of that, any other solutions?

    Thanks!
  7. Deyan
    Admin
    Deyan avatar
    2041 posts

    Posted 06 Feb 2014 Link to this post

    Hello Eugene,

    Actually sorting can be either ascending or descending. The groups in either case are sorted based on the value of the group key. So, if you want to have custom sorting approach, you can define a generic group descriptor that returns  a composite object instead of a string for the group key. That composite object implements IComparable and overrides Equals. If you have some code to share I can help you by implementing this for you.

    Hope this helps.

    Regards,
    Deyan
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peek previews directly from the developers working on the UI for Windows Phone, subscribe to the blog feed now.
  8. Asdrubal
    Asdrubal avatar
    1 posts
    Member since:
    Oct 2007

    Posted 14 Apr 2014 in reply to Deyan Link to this post

    Hi,

    The composite object + IComparable + override Equals works great for custom sorting group descriptor!

    But... now I having this problem, I the base.ToString() text of the composite Object in design mode, not the overridden ToString() for the class

    Dont get me wrong, It works great at run time, its in design mode the problem (Blendability issues)

    Thanks










  9. Deyan
    Admin
    Deyan avatar
    2041 posts

    Posted 17 Apr 2014 Link to this post

    Hi Asdrubal,

    You can perform a check to see if your component is currently in design mode or not:

    if (DesignerProperties.GetIsInDesignMode(this))
           {
               // Design-mode specific functionality
           }


    Regards,
    Deyan
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top
DevCraft banner