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

display totals in grid header instead of footer?

4 Answers 363 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dave
Top achievements
Rank 1
Dave asked on 11 Jul 2011, 11:53 PM
I have a project requirement to show the totals from my radgrid in the header instead of the footer because the users don't want to have to scroll down to the bottom of the grid to see the totals. Is this possible? I know how to do it in the footer based on this article, but can it easily be done in the header? If not, I guess I'll have to switch to a RadListView which is going to be a bit of a pain, but not sure what else to do.

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 12 Jul 2011, 07:46 AM
Hello Dave,

Check the following help article which explains how to perform calculations in group header.
Performing calculations in group header.

Thanks,
Princy.
0
Dave
Top achievements
Rank 1
answered on 12 Jul 2011, 03:30 PM
I'd rather not use grouping to do it. I want it to look just like the footer aggregates, but obviously appear in the header.
0
Radoslav
Telerik team
answered on 15 Jul 2011, 11:49 AM
Hello Dave,

Unfortunately the RadGrid does not support build in the desired functionality. However with the following code snippet you could show the footer aggregates into the RadGrid header:
protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
 
        RadGrid1.PreRender += new EventHandler(RadGrid1_PreRender);
    }
 
    void RadGrid1_PreRender(object sender, EventArgs e)
    {
        GridHeaderItem header = RadGrid1.MasterTableView.GetItems(GridItemType.Header)[0] as GridHeaderItem;
        GridFooterItem footer = RadGrid1.MasterTableView.GetItems(GridItemType.Footer)[0] as GridFooterItem;
 
        foreach (var column in RadGrid1.MasterTableView.RenderColumns)
        {
            var value = footer[column.UniqueName].Text;
            header[column.UniqueName].Text += "<br/>" +  value;
        }
    }

Additionally I am sending you a simple example which demonstrates the desired functionality. Please check it out and let me know if it helps you.

Looking forward for your reply.

Kind regards,
Radoslav
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Jaicon
Top achievements
Rank 1
answered on 03 Feb 2016, 05:33 PM

This work fine for me:

protected void RadGrid1_PreRender(object sender, EventArgs e)
        {
            foreach (GridGroupFooterItem groupFooter in RadGrid1.MasterTableView.GetItems(GridItemType.GroupFooter))
            {
                string value = groupFooter["uniqueName"].Text;

                foreach (GridGroupHeaderItem groupHeader in RadGrid1.MasterTableView.GetItems(GridItemType.GroupHeader))
                {
                    if (groupHeader.GroupIndex == groupFooter.GroupIndex)
                    {
                        groupHeader.DataCell.Text += " " + value;
                    }
                }
            }
        }

Tags
Grid
Asked by
Dave
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Dave
Top achievements
Rank 1
Radoslav
Telerik team
Jaicon
Top achievements
Rank 1
Share this question
or