This is a migrated thread and some comments may be shown as answers.

Maintain Scroll Position and Group Expansions on PropertyChange

2 Answers 175 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Lay Hooi
Top achievements
Rank 1
Lay Hooi asked on 28 Feb 2013, 05:08 AM
I am using a Gridview with 2 default column groupings based on the properties Status and Company. I am using ContextMenu to update the Status on all the rows under the clicked Company group. 

The grid grouping looks something like this. 

  • Status = Invited
- Company A
- Company B
  • Status = Excluded
- Company C

Issue 1: Updating the status on each row fires the PropertyChanged and the grid is refreshed and scrolled to the top. I have about 100 groups of company and would like to maintain the scroll position after the status has been updated via the context menu.

Issue 2: At the moment, I am collapsing all Company groups using the DataLoaded event. These groups will be collapsed again when the status on any of the rows have been updated even if the user has expanded some of them. Is there a way to make it maintain the group expansion state after the data update? 

Telerik Version: 2011.1.419.1040

This is the Xaml:
<radGrid:RadGridView x:Name="grdInvitee"
                                 Margin="0 0 0 0"
                                 MaxHeight="300"
                                 MaxWidth="1120"                                
                                 HorizontalAlignment="Left"
                                 ShowGroupPanel="False"
                                 AutoGenerateColumns="False"
                                 AutoExpandGroups="True"
                                 ItemsSource="{Binding InviteeList}"
                                 EditTriggers="CellClick"                                
                                 CanUserDeleteRows="False"
                                 CanUserInsertRows="False">
                <telerik:RadContextMenu.ContextMenu>
                    <telerik:RadContextMenu x:Name="Menu" Opened="MenuOpened"></telerik:RadContextMenu>
                </telerik:RadContextMenu.ContextMenu>

Code for collapsing 2nd level groups:
private void grdInvitee_DataLoaded(object sender, EventArgs e)
{
    // collapse all child groups (organisation group)           
    foreach (IGroup parentGrp in grdInvitee.Items.Groups)
    {
        foreach (IGroup childGrp in parentGrp.Subgroups)
        {
            grdInvitee.CollapseGroup(childGrp);
        }               
    }                         
}      

2 Answers, 1 is accepted

Sort by
0
TMatt
Top achievements
Rank 2
answered on 10 Apr 2013, 01:14 PM
We're facing the same issue (#1), using Version 2013.1.403.1050 of RadControls when the ItemsSource is updated from a background thread. Did you make any progress in solving this?
0
Nedyalko Nikolov
Telerik team
answered on 15 Apr 2013, 11:17 AM
Hello Lay Hooi,

#1. You could maintain the scroll position with a simple call to ScrollIntoView() method, or with radGridView.VirtualizingPanel.SetVerticalOffset() (you may cast VirtualizingPanel to IScrollInfo).

#2. RadGridView has a property "AutoExpandGroups" and this is the property which controls if a group will be expanded or collapsed. In your case changing the data results in creating a new group (for which there is no record about its state, therefore "AutoExpandGroups" is taken into account).

Hi Tobias,

Could you please elaborate a little bit what updating of an ItemsSource from a background thread means? Do you mean that the entire ItemsSource is changed? In this case RadGridView will scroll to the top. If you just change a few items (via INotifyCollectionChanged interface) then RadGridView should not scroll to the top. 

Greetings,
Nedyalko Nikolov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
Lay Hooi
Top achievements
Rank 1
Answers by
TMatt
Top achievements
Rank 2
Nedyalko Nikolov
Telerik team
Share this question
or