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

GroupBy item count in group header

1 Answer 339 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tom
Top achievements
Rank 1
Tom asked on 21 Jan 2016, 03:24 PM

We have 20 declared columns (NOT using auto-generated columns) and the user can use the context menu to group by any column and have nested groupings. The default is no grouping. I set the Aggregate="Count" property on the primary ID databound field. The counts get displayed in the footer but I want to display them in the header next to the header text. Also the  catch with this approach is that if that column is hidden (user can decide which columns to view), the totals do not show up. I simply want to add a count of the number of records/items that are in each group.

I tried using ItemDataBound checking for GridGroupHeaderItem but all of the AggregatesValues for the item are null.

Here is what I've tried in the itemdatabound event.

protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridGroupHeaderItem)
    {
        GridGroupHeaderItem item = (GridGroupHeaderItem)e.Item;
        int c1 = item.GetChildItems().Length; //always 0
        int c2 = item.GetChildItems().Count() //always 0
    }
}

1 Answer, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 26 Jan 2016, 03:30 PM
Hello,

Refer to the forum thread below where the same question is discussed:
http://www.telerik.com/forums/display-totals-in-grid-header-instead-of-footer

Regards,
Pavlina
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Tom
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Share this question
or