example with single group expanded and all others collapsed.

2 posts, 0 answers
  1. Hazzard
    Hazzard avatar
    24 posts
    Member since:
    May 2006

    Posted 03 Jan 2012 Link to this post

    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; }
           }

     

  2. Hazzard
    Hazzard avatar
    24 posts
    Member since:
    May 2006

    Posted 03 Jan 2012 Link to this post

    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>
Back to Top