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

Group name along with footer total?

1 Answer 90 Views
Grid
This is a migrated thread and some comments may be shown as answers.
John St. Amant
Top achievements
Rank 1
John St. Amant asked on 28 Jul 2008, 05:42 PM
How can I place the 'Group' name among each footer total?

For example, I have a group defined:  GridGroupByField FieldName="GroupRegion".  The group will be text such as "East Coast", "West Coast", etc. 

I want to use that group value in each Footer total. i.e.  "East Coast Total = 99", West Coast Total = 101".

I thought maybe something I could add via code in the ItemDataBound event?:

If (TypeOf e.Item Is GridFooterItem) Then
   Dim footerItem As GridFooterItem = CType(e.Item, GridFooterItem)
   footerItem("SumOfRegion").Text = ??
End If

But, I don't know how to get the current group value / name the footer total is working with...?

Thanks.

1 Answer, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 29 Jul 2008, 09:18 AM
Hello John,

You are correct in your supposition, you need to get the GridGroupFooterItem in ItemDataBound:

void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    if (e.Item is GridGroupFooterItem) 
    { 
        GridGroupFooterItem item = e.Item as GridGroupFooterItem; 
        string newValue = item.OwnerTableView.Items[item.OwnerTableView.Items.Count - 2]["GroupRegion"].Text; 
        item.Cells[6].Text = item.Cells[6].Text.Replace("Sum""GroupRegion:" + newValue); 
    } 

The above code gets a reference to the currently created GridGroupFooterItem, references the needed data cell by index and replaces the default footer text (the name of the aggregate) with a custom text derived from the previous item's "GroupRegion" field value.

Greetings,
Veli
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
John St. Amant
Top achievements
Rank 1
Answers by
Veli
Telerik team
Share this question
or