Default sorting of items

6 posts, 0 answers
  1. Alexander
    Alexander avatar
    78 posts
    Member since:
    Apr 2013

    Posted 24 Mar 2015 Link to this post

    When you group or sort the GridView by one column and afterwards change the corresponding property, the items are more or less randomly inserted in the list.
    In my case, the items have some natural sorting by some item number (as indicated by the underlying ItemsSource). There is a property which determines the ordering, however this is not exposed as a column.

    Is there any way to force the items to keep this order (inside their respective groups)?

    Alex
  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 25 Mar 2015 Link to this post

    Hi Alex,

    You can specify the SortMemberPath property of the column to be the property determining the ordering. Then, you will need to have the column sorted Ascending or Descending. How does this work for you?

    Regards,
    Dimitrina
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  3. Alexander
    Alexander avatar
    78 posts
    Member since:
    Apr 2013

    Posted 25 Mar 2015 in reply to Dimitrina Link to this post

    Sorry, I think I didn't make it clear enough.

    I am grouping by the column "Group" and then change the group of some items.
    Now the items are in the wrong order inside the groups (e.g. M2 comes after M10; and M3 being at the bottom of the grid - not in the window any more and not in the first row of the third group, where I would expect it to be).
    So the first column should be kept sorted (without having to specify a SortDescriptor).
  4. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 26 Mar 2015 Link to this post

    Hi Alex,

    Would you please share some more details on how do you insert the items? Basically, in case there is not any SortDescriptor added, RadGridView should display them as they are ordered in the bound source collection. The way RadGridView can control the order would be through adding a proper sorting descriptor.

    Regards,
    Dimitrina
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  5. Alexander
    Alexander avatar
    78 posts
    Member since:
    Apr 2013

    Posted 26 Mar 2015 in reply to Dimitrina Link to this post

    There is no insertion involved.

    When there is no Grouping/Sorting active, the items appear in the correct order (as in the source collection, where they are always ordered).
    When you activate Grouping and/or Sorting, the order (inside the group) stays correct.
    However, when I edit the group of an item while Grouping is active, then it is sometimes moved at the wrong position (and therefore difficult to find).
    The order is correct again when we sort by the id column and then remove the sort descriptor again.

    I don't want to put a sort descriptor on the first column, as this would have to be "fixed" - but maybe the user wants to sort by some other column...
  6. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 27 Mar 2015 Link to this post

    Hello Alex,

    Thank you for clarifying this. As it turns out this logic when RadGridView is grouped cannot be overcame. Basically grouping in RadGridView is a data operation. The default grouping occurs as the user drags a column header and drops it into the GroupPanel. Then, we internally generate and execute a LINQ query appending a GroupBy clause to the source collection. While grouping is active, every time when a CollectionChanged notification is raised (for example as you are editing an item), then the GroupDescriptor is reevaluated and that is why you experience the non-desired effect.

    Regards,
    Dimitrina
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
Back to Top