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

example with single group expanded and all others collapsed.

1 Answer 102 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Hazzard
Top achievements
Rank 1
Hazzard asked on 03 Jan 2012, 11:53 PM
Do you have example code using GroupDescriptors in XAML and the codebehind which will expand or contract based on the GroupDescriptor's Member Property?  Should the following code work together to achieve the expanding of only certain groups based upon values bound to the Grid, in the following - Member="PSEType"  Thank you.

 

 

 

<telerik:RadGridView Name="rgvProductInfo"  
                     Loaded="rgvProductInfo_Loaded" 
                     ShowGroupPanel="True" 
                     AutoGenerateColumns="False" 
                     Grouped="gridView_Grouped"
                     ItemsSource="{Binding PSEItemsCompletedList}" >
    <telerik:RadGridView.GroupDescriptors>
        <telerikData:GroupDescriptor Member="PSEType" DisplayContent="PSE Type"/>
    </telerik:RadGridView.GroupDescriptors>
    <telerik:RadGridView.Columns>

 

 

private void rgvProductInfo_Loaded(object sender, System.Windows.RoutedEventArgs e)
 {
      var grped = rgvPSEProductInfo.ChildrenOfType<GridViewGroupRow>();
      foreach (GridViewGroupRow groupRow in grped)
      {
              if (groupRow.Group.Key.ToString() == "General Info")
                  groupRow.IsExpanded = true;
     }
}

 

 

this.DataContext = _viewModel.PSEItemsCompletedList;
private List<PSEItemsCompletedModel> __pseItemsCompletedList;
       public List<PSEItemsCompletedModel> PSEItemsCompletedList  //list of items bound to grid
       {
           set
           {
               __pseItemsCompletedList = value;
               FirePropertyChanged("PSEItemsCompletedList");
           }
           get { return __pseItemsCompletedList; }
       }

 

1 Answer, 1 is accepted

Sort by
0
Hazzard
Top achievements
Rank 1
answered on 04 Jan 2012, 12:40 AM
and if I try the other recommended approach, gridview_Grouped never fires, but I realize I need this on Load, when the page Loads, so I don't think the Grouped event is what I want anyway.
void gridView_Grouped(object sender, Telerik.Windows.Controls.GridViewGroupedEventArgs e)
       {
              this.rgvProductInfo.ExpandGroup(this.rgvProductInfo.Items.Groups[0] as IGroup);
              this.rgvProductInfo.ExpandGroup(this.rgvProductInfo.Items.Groups[1] as IGroup);
       }

<telerik:RadGridView Name="rgvProductInfo"  
                             EnableRowVirtualization="False" 
                             ShowGroupPanel="True" 
                             AutoGenerateColumns="False" 
                             Grouped="gridView_Grouped"
                             ItemsSource="{Binding PSEItemsCompletedList}" >
            <telerik:RadGridView.GroupDescriptors>
                <telerikData:GroupDescriptor Member="PSEType" DisplayContent="PSE Type"/>
            </telerik:RadGridView.GroupDescriptors>
Tags
GridView
Asked by
Hazzard
Top achievements
Rank 1
Answers by
Hazzard
Top achievements
Rank 1
Share this question
or