display totals in grid header instead of footer?

5 posts, 0 answers
  1. Dave
    Dave avatar
    36 posts
    Member since:
    Jan 2008

    Posted 11 Jul 2011 Link to this post

    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.
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 12 Jul 2011 Link to this post

    Hello Dave,

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

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Dave
    Dave avatar
    36 posts
    Member since:
    Jan 2008

    Posted 12 Jul 2011 Link to this post

    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.
  5. Radoslav
    Admin
    Radoslav avatar
    1564 posts

    Posted 15 Jul 2011 Link to this post

    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!

  6. Jaicon
    Jaicon avatar
    3 posts
    Member since:
    Feb 2016

    Posted 03 Feb Link to this post

    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;
                        }
                    }
                }
            }

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017