Count Groups?

4 posts, 0 answers
  1. ITA
    ITA avatar
    383 posts
    Member since:
    Aug 2009

    Posted 29 Jul 2012 Link to this post

    Hi,

    is it possible to count the Groups in a GridView and also get the Group Header?

    Thanks
    Best Regards
    Rene
  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 30 Jul 2012 Link to this post

    Hi Rene,

     You can use the GroupCount property of the RadGridView to count the groups. As to the group header, may I ask you to share some more details on why do you need to access it?

    Regards,
    Didie
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. UI for WPF is Visual Studio 2017 Ready
  4. ITA
    ITA avatar
    383 posts
    Member since:
    Aug 2009

    Posted 30 Jul 2012 Link to this post

    Hi,

    ok, i have a RadGridView which contains 1 up to 10 Groups. In Codebehind i have to check each Group in the GridView.
    For each Group i have to to somethink different, so i have to no which Groups are in the GridView.
    Fas GridView contains a collection of different modules

    Grid.jpg: The Grid with all possible Groups

    I need somethink like
    foreach(RadGridViewGroup Ggroup in RadGridView.Groups)
    {
        // do somethink
    }

    Thanks
    Best Regards
    Rene
  5. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 31 Jul 2012 Link to this post

    Hi,

    You could get the visible GroupRows using the ChildrenOfType method. An example with the first GridViewGroupRow would be: 

    GridViewGroupRow groupRow = this.clubsGrid.ChildrenOfType<GridViewGroupRow>().FirstOrDefault();
    if (groupRow != null)
    {
       GroupViewModel groupViewModel = groupRow.GroupViewModel as GroupViewModel;
       object header = groupViewModel.Header;
    }

     Generally I would better advise you to predefine the GroupHeaderTemplate of the GridView/GridViewColumns although I am not sure if this will meet your needs. Please check the Totals WPF Demo for an example on how to predefine it. 

    Regards,
    Didie
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top