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

GroupHeader Count

2 Answers 56 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Zed
Top achievements
Rank 1
Zed asked on 08 Jul 2009, 02:43 PM
I need to get a count of all items each time a group changes, for example:

year 2008: 100
  month January 3
  record 1
  record 2
  record 3
  month February 5
  record 4
  record 5
  record 6
  record 7
  record 8

etc
I have this code, but it only gets the group header having children records, and not the top level (year)

 foreach (GridGroupHeaderItem groupHeader in rgTickets.MasterTableView.GetItems(GridItemType.GroupHeader))
            {

                Created = Closed = 0;
                GridItem[] children = groupHeader.GetChildItems();
                try
                {
                    foreach (GridItem child in children)
                    {
                        GridDataItem dataItem = child as GridDataItem;
                        Created += Convert.ToInt32(dataItem["Created"].Text);
                        Closed += Convert.ToInt32(dataItem["Closed"].Text);
                    }

                    // strCount = children.Sum(n => Convert.ToInt32(n.Cells[5].Text));
                    groupHeader.DataCell.Text += "    Created:  " + Created.ToString();
                    groupHeader.DataCell.Text += "    Closed:  " + Closed.ToString();

                }
                catch (Exception ex)
                {

 

                }
              

            }





2 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 10 Jul 2009, 11:13 AM
Hello Zed,

Another possible option in this case would be to use the footer aggregates, where you can include the Count aggregate, showing all the items within the group automatically.

Regards,
Yavor
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Zed
Top achievements
Rank 1
answered on 10 Jul 2009, 11:54 AM
I came to the same conclusion independently.  It shows great minds work alike :).  I opened a thread on that subject and Pavlina answered.
Tags
Grid
Asked by
Zed
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Zed
Top achievements
Rank 1
Share this question
or