GroupDescriptors disappear after changing ItemsSource to empty/null

9 posts, 0 answers
  1. MB
    MB avatar
    23 posts
    Member since:
    Aug 2007

    Posted 29 Oct 2010 Link to this post

    1) Bind collection to GridView
    2) Group on a column
    3) set the collection to a new empty collection, or set grid itemssource = null

    You should notice that the columns are still on the grid, but the group is removed.

    We are trying to persist grouping options across different sets of data, when hitting an empty dataset, the grouping is lost.

    The _Grouped and _Grouping events are not fired, however a manual check shows that the GroupDescriptors are indeed cleared.

    (This is using Q3 Beta but it was the same behaviour in previous versions)
  2. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 29 Oct 2010 Link to this post

    Hi,

    This is by design. You can save the group descriptors somewhere before resetting the data and add them to the GroupDescriptors collection after the data has come.

    All the best,
    Veselin Vasilev
    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
  3. DevCraft banner
  4. Martin
    Martin avatar
    10 posts
    Member since:
    Feb 2011

    Posted 25 Feb 2011 Link to this post

    Just ran into this myself, curious as to why this design choice was made? I would think the grids meta data (column, group descriptors, etc) would persist across different items sources?

    Marty
  5. Yavor Georgiev
    Admin
    Yavor Georgiev avatar
    982 posts

    Posted 26 Feb 2011 Link to this post

    Hello Marty,

     When the ItemsSource of a RadGridView is changed, there is no guarantee that the columns and descriptors defined will be applicable to the type of the new data items. That is why, rather than risking exceptions in the LINQ runtime, they are cleared.

    Greetings,
    Yavor Georgiev
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  6. Ivan
    Ivan avatar
    6 posts
    Member since:
    Jul 2012

    Posted 24 Apr 2013 Link to this post

    How ???
  7. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 25 Apr 2013 Link to this post

    Hello,

    By calling the Collection<T>.Clear method of the respective collection.

    Kind regards,
    Rossen Hristov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  8. Lukas
    Lukas avatar
    4 posts
    Member since:
    Sep 2014

    Posted 08 Jul 2015 Link to this post

    Well... Yes, it is not guaranteed that the group descriptors still work. But wouldn't that be my fault? This is quite contra-intuitive behavior, especially if I set the group descriptors in XAML.
  9. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 08 Jul 2015 Link to this post

    Hi,

    Thank you for sharing your feedback.

    Regards,
    Dimitrina
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
  10. Shawn
    Shawn avatar
    5 posts
    Member since:
    Jun 2011

    Posted 05 Oct 2015 Link to this post

    Hi guys, doesn't seem like telerik was much help on this at all.  I encountered the same issue in my project where I was setting the ColumnGroupDescriptor of a RadGrid GroupDescriptor through my XAML.  At some point the screen would rebind the RadGrid to null and then back to a valid list.  At this point my grouping was completely lost.

     

    I hate programatically setting binding but in this instance, I passed the RadGrid to my ViewModel as a method parameter from a trigger event and in the corresponding method linked to that trigger, I set the itemsource and a new GroupDescriptor.  This worked and allowed the grouping to reappear each time the Grid was set to null and then back to a list.I had to remove the GroupDescriptor definition in the XAML as well.

    Sample of C# code to set Group Descriptor Programatically:

     

    GroupDescriptor descriptor = new GroupDescriptor();
    descriptor.Member = "NAME_OF_MY_COLUMN";
    descriptor.SortDirection = ListSortDirection.Ascending;
    thisAllocationGrid.GroupDescriptors.Add(descriptor);
Back to Top
DevCraft banner