Datagrid - DataGridGroupRow - control over expand / collapse

Posted by: appmod on 7 August 2017, 8:11 am EST

    • Post Options:
    • Link

    Posted 7 August 2017, 8:11 am EST

    I have a datagrid with itemsource bound to an observable collection.

    If the user uses the grouping feature, and collapses 1 (or more) groups…

    But in the background (on timer) we have newer records arriving in to our collection…

    The datagrid will always refresh with all groups expanded.

    I need a way to remember which group values are collapsed, and after each refresh (to itemsource) I can re-collapse the correct entries (assuming they still exist of course).

    This person also had a similar question:

    Any tips/ suggestions (or can it be done)?

    Thanks in advance.


  • Posted 7 August 2017, 8:11 am EST

    I think you can save the ‘GroupRowsVisibility’ values using a dictionary and apply those values later on after the refresh. So, try something like this to save the GroupRowsVisibility values:-

    [csharp] Dictionary<int, Visibility> rowvisibilityvalues = new Dictionary<int, Visibility>();

    foreach (var row in grid.Rows)


    if (row.Type == DataGridRowType.Group)


    rowvisibilityvalues[row.Index] = (row as DataGridGroupRow).GroupRowsVisibility;



    You can manually apply the values like this:-

    [csharp]foreach (var row in GridA.Rows)


    if (row.Type == DataGridRowType.Group)


    (row as DataGridGroupRow).GroupRowsVisibility = rowvisibilityvalues[row.Index] ;



    Let me know if you face any further issues/questions.


  • Posted 7 August 2017, 8:11 am EST

    Wondering if this is still the only way to keep groups from auto-expanding after a refresh.

    If so, are there recommended Grid events to perform this manual saving / retrieving of grid settings?


  • Posted 7 August 2017, 8:11 am EST

    How is the refresh occurring in your case? Is it a change in the bound ItemsSource or what?

    If you are changing the itemssource manually, you can update the ItemsSource between the above methods.


  • Posted 20 January 2020, 4:06 am EST

    C1upkar_s, this does not seem to work. If I read the property

    I always get
    , regardless of the situation for the group, expanded or collapsed doesn’t matter.

    Any idea?



  • Posted 20 January 2020, 10:30 pm EST


    I have prepared for you a solution that stores the expand/collapse state of grouped rows in C1DataGrid. For details, please refer the attached application.

    Hopefully this should help.



Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels