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

Sum in Group Header and Grid Footer

3 Answers 621 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Adam Pehas
Top achievements
Rank 1
Adam Pehas asked on 20 Jul 2010, 03:37 PM
I'm having an issue with the Aggergate="Sum"  I have a bunch of invoices with fees on them.  I needs to display the data grouped by invoice and show the total of the fees in the group header along with a Grand total in the footer of the entire grid. 

I'm using the following markup to do that.  The issue is that when I include the SUM for the grand total in the footer.  The Group header will only show the value of the last item in that group.  The group header no longer rolls or sums up the fees in the group.

<telerik:RadGrid ID="rgFees" runat="server" AutoGenerateColumns="false" ShowFooter="True"
    Skin="Web20" Height="500px">
    <ClientSettings>
        <Scrolling AllowScroll="True" UseStaticHeaders="True" />
    </ClientSettings>
    <MasterTableView ShowGroupFooter="true" AllowMultiColumnSorting="true" GroupLoadMode="Client">
        <Columns>
            <telerik:GridBoundColumn DataField="FeeDescription" HeaderText="Fee Description">
            </telerik:GridBoundColumn>
  
             <telerik:GridBoundColumn Aggregate="Sum" DataField="TotalFee" HeaderText="Total*"
                FooterText="Total" DataFormatString="{0:C}">
            </telerik:GridBoundColumn>      
  
            <telerik:GridBoundColumn DataField="InvoiceId" HeaderText="Invoice Number">
            </telerik:GridBoundColumn>
        </Columns>
        <GroupByExpressions>
            <telerik:GridGroupByExpression>
                <GroupByFields>
                    <telerik:GridGroupByField FieldName="InvoiceId" HeaderText="" />
                </GroupByFields>
                <SelectFields>
                    <telerik:GridGroupByField FieldName="InvoiceId" HeaderText="  " HeaderValueSeparator="Invoice # " />
                    <telerik:GridGroupByField FieldName="TotalFee" HeaderText="            "
                        HeaderValueSeparator="Total: " Aggregate="Sum" FormatString="{0:C}" />
                </SelectFields>
            </telerik:GridGroupByExpression>
        </GroupByExpressions>
    </MasterTableView>
    <ClientSettings AllowDragToGroup="false" />
    <GroupingSettings ShowUnGroupButton="false" />
</telerik:RadGrid>





The following Code works and gives the correct group header sum.  How do I get a GRAND TOTAL to show up in the footer for the entire grid.



<telerik:RadGrid ID="rgFees" runat="server" AutoGenerateColumns="false" ShowFooter="True"
    Skin="Web20" Height="500px">
    <ClientSettings>
        <Scrolling AllowScroll="True" UseStaticHeaders="True" />
    </ClientSettings>
    <MasterTableView ShowGroupFooter="true" AllowMultiColumnSorting="true" GroupLoadMode="Client">
        <Columns>
            <telerik:GridBoundColumn DataField="FeeDescription" HeaderText="Fee Description">
            </telerik:GridBoundColumn>
  
             <telerik:GridBoundColumn   DataField="TotalFee" HeaderText="Total*"
                FooterText="Total" DataFormatString="{0:C}">
            </telerik:GridBoundColumn>      
  
            <telerik:GridBoundColumn DataField="InvoiceId" HeaderText="Invoice Number">
            </telerik:GridBoundColumn>
        </Columns>
        <GroupByExpressions>
            <telerik:GridGroupByExpression>
                <GroupByFields>
                    <telerik:GridGroupByField FieldName="InvoiceId" HeaderText="" />
                </GroupByFields>
                <SelectFields>
                    <telerik:GridGroupByField FieldName="InvoiceId" HeaderText="  " HeaderValueSeparator="Invoice # " />
                    <telerik:GridGroupByField FieldName="TotalFee" HeaderText="            "
                        HeaderValueSeparator="Total: " Aggregate="Sum" FormatString="{0:C}" />
                </SelectFields>
            </telerik:GridGroupByExpression>
        </GroupByExpressions>
    </MasterTableView>
    <ClientSettings AllowDragToGroup="false" />
    <GroupingSettings ShowUnGroupButton="false" />
</telerik:RadGrid>


3 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 21 Jul 2010, 02:23 PM
Hello Adam,

I suggest that you examine the online resources below and see if they help:
http://demos.telerik.com/aspnet-ajax/grid/examples/groupby/groupfooter/defaultcs.aspx
http://www.telerik.com/help/aspnet-ajax/grdperformcalculationsingroupheader.html

All the best,
Pavlina
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
Jaicon
Top achievements
Rank 1
answered on 03 Feb 2016, 05:35 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;
                    }
                }
            }
        }
0
Pavlina
Telerik team
answered on 04 Feb 2016, 11:39 AM
Hello Jaicon,

Thank you for sharing your solution with the community.

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
Adam Pehas
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Jaicon
Top achievements
Rank 1
Share this question
or