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

Group Aggregate incorrect and footertext not showing

10 Answers 473 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jon Ingersoll
Top achievements
Rank 1
Jon Ingersoll asked on 21 Apr 2010, 05:54 PM
I'm having two issues with my radgrid

1) I have a aggregate group column that instead of showing the sum of the column is showing the last value in column.
2) Since the grouping wasn't working I turned on the groupfooters to show the aggregate sum, but the FooterText is not showing in the footer.

As far as I can tell, I've followed the demos exactly to use both those features.

I've attached a screen shot of the output, notice in the group header that the sum of the cost is wrong and in the footer while the cost sum is correct, the text "Total: " isn't showing.

-Jon

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="GuestAdmin.ascx.cs" Inherits="GuestAdmin" %> 
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %> 
<telerik:RadGrid ID="GridReunionGuests" AllowFilteringByColumn="False" AllowPaging="True" 
    Skin="Vista" AllowSorting="False" runat="server" AutoGenerateColumns="False" 
    DataSourceID="ReunionGuestsDataSource" GroupingEnabled="true"
    <MasterTableView DataKeyNames="ReunionGuestsID" DataSourceID="ReunionGuestsDataSource" ShowGroupFooter="true"
        <Columns> 
            <telerik:GridBoundColumn DataField="FirstName" HeaderText="First" /> 
            <telerik:GridBoundColumn DataField="LastName" HeaderText="Last" /> 
            <telerik:GridBoundColumn DataField="Age" HeaderText="Age" /> 
            <telerik:GridDropDownColumn DataField="GuestOptionsID" DataSourceID="GuestOptionsDataSource" 
                HeaderText="Options" ListTextField="GuestOption" ListValueField="GuestOptionsID" 
                UniqueName="GuestOption"
            </telerik:GridDropDownColumn> 
            <telerik:GridDropDownColumn DataField="RelationShipsID" DataSourceID="RelationShipsDataSource" 
                HeaderText="Relationship" ListTextField="Description" ListValueField="RelationShipsID" 
                UniqueName="RelationShip"
            </telerik:GridDropDownColumn> 
            <telerik:GridBoundColumn DataField="SpecialRequirements" HeaderText="Special Requirements" /> 
            <telerik:GridBoundColumn DataField="ReunionYear" HeaderText="Reunion" /> 
            <telerik:GridBoundColumn DataField="DateStamp" HeaderText="Date Stamp" /> 
            <telerik:GridDropDownColumn DataField="RegStatusID" DataSourceID="RegStatusDataSource" 
                HeaderText="Status" ListTextField="RegistrationStatus" ListValueField="RegStatusID" 
                UniqueName="Status"
            </telerik:GridDropDownColumn> 
            <telerik:GridBoundColumn DataField="Cost" HeaderText="Cost" FooterText="Total: " Aggregate="Sum" DataFormatString="{0:C}" ItemStyle-HorizontalAlign="Right" DataType="System.Double" /> 
        </Columns> 
        <GroupByExpressions> 
                        <telerik:GridGroupByExpression> 
                            <SelectFields> 
                                <telerik:GridGroupByField HeaderText="Transaction ID" FieldName="transactiongroup"></telerik:GridGroupByField> 
                                <telerik:GridGroupByField FieldName="Email"></telerik:GridGroupByField> 
                                <telerik:GridGroupByField HeaderText="Customer ID" FieldName="CUSTID"></telerik:GridGroupByField> 
                                <telerik:GridGroupByField HeaderText="Cost" FieldName="Cost" Aggregate="Sum"></telerik:GridGroupByField> 
                             </SelectFields> 
                            <GroupByFields> 
                                <telerik:GridGroupByField FieldName="transactiongroup"></telerik:GridGroupByField> 
                            </GroupByFields> 
                        </telerik:GridGroupByExpression> 
                    </GroupByExpressions> 
    </MasterTableView> 
</telerik:RadGrid> 
<asp:SqlDataSource ID="ReunionGuestsDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:edu_yale_som_alumnireunion_connectionstring %>" 
    ProviderName="System.Data.SqlClient" SelectCommand="SELECT * FROM [ReunionGuests] WHERE Submitted='true'"
</asp:SqlDataSource> 
<asp:SqlDataSource ID="GuestOptionsDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:edu_yale_som_alumnireunion_connectionstring %>" 
    ProviderName="System.Data.SqlClient" SelectCommand="SELECT [GuestOptionsID], [GuestOption] FROM [GuestOptions] WHERE Visible='true' order by DisplayOrder"
</asp:SqlDataSource> 
<asp:SqlDataSource ID="RelationShipsDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:edu_yale_som_alumnireunion_connectionstring %>" 
    ProviderName="System.Data.SqlClient" SelectCommand="SELECT [RelationShipsID], [Description] FROM [RelationShips]"
</asp:SqlDataSource> 
<asp:SqlDataSource ID="RegStatusDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:edu_yale_som_alumnireunion_connectionstring %>" 
    ProviderName="System.Data.SqlClient" SelectCommand="SELECT [RegStatusID], [RegistrationStatus] FROM [RegStatus]"
</asp:SqlDataSource> 
 

10 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 23 Apr 2010, 01:31 PM
Hi Jon,

I reviewed the setup, and it looks correct.
If the issue persists, you can open a formal support ticket, and send a small project, demonstrating your setup, and showing the unwanted behavior. We will debug it locally, and get back to you with more information on the matter.

Best wishes,
Yavor
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
Jeremy Mann
Top achievements
Rank 1
answered on 08 Oct 2010, 08:36 PM
I'm having the same issue:  I have a aggregate group column [in a grouping header] that instead of showing the sum of the column is showing the last value in column.

So instead of getting the sum aggregate, it's displaying the columns last row's value.  Interestingly, if I change the Aggregate from "sum" to "avg" I incorrectly get the value of the last row, divided by the number of items in the group (instead of sum divided by number of items in group). So that tells me the AVG function is also falining to "sum" the groups column. 

Did this ever get an answer?
0
Pavlina
Telerik team
answered on 13 Oct 2010, 10:33 AM
Hi Jeremy,

In the following help article are the steps you need to undertake to display totals in the grid columns footer:
Totals in grid footers

I hope this helps.

Regards,
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
Jeremy Mann
Top achievements
Rank 1
answered on 14 Oct 2010, 02:38 PM
Hi Pavlina,

I'm aware of how to manually do the calculations, but my question was more of pointing out there is a bug or issue with the way the radgrid is doing aggregates on grouped columns.  Please note my issue is occurring not in the footer, but in the grouping text. When you set the Aggregate mode to "Sum" and it doesn't "Sum", but instead gives only the value of the last record, thats a bug or problem. My work around is to do it manually as I still need to get my work done, but this becomes a pain with many groups or columns when the radgrid control is already suppose to cover this functionality; Which the radgrid does... it just doesn't do it correctly.   If Telerik cannot duplicate this issue, I can try to send a sample project when I wrap up what I'm working on in two weeks.  

Thanks for looking into it and your previous response.

-Jeremy
0
Pavlina
Telerik team
answered on 15 Oct 2010, 04:56 PM
Hello Jeremy,

In this case I would ask you to open a formal support ticket and send us a runnable sample. We will debug it locally and thus find the source of the problem and a suitable resolution.

Greetings,
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
Fred
Top achievements
Rank 1
answered on 08 Nov 2010, 06:58 PM
   Any answer on this? I'm having the same problem too...


 Fred.
0
Pavlina
Telerik team
answered on 10 Nov 2010, 04:10 PM
Hello Fred,

In order to show the totals in group header FieldAlias property should be set for the SelectFields as shown below:
ASPX:
<SelectFields>
           <telerik:GridGroupByField
           FieldName="UnitsInStock" 
           FieldAlias="FieldAlias1"
           HeaderText="Units at this price"
           Aggregate="Sum" />
      </SelectFields>

Give it a try and let me know how it goes.

Kind regards,
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
George Felipe
Top achievements
Rank 1
answered on 10 Nov 2010, 09:26 PM
This still doesn't work. I am also having issues with Group Aggregates only showing the value of the last record of that group.

I simply do this code in the background:

string var = "SalesRep [Sales Rep], count(RecordNum) RecordNum [Count], Sum(TotalSplit) TotalSplit [Total Split] Group By SalesRep";
 
grdBillings.MasterTableView.GroupByExpressions.Add(GridGroupByExpression.Parse(var));
grdBillings.Rebind();

TABLE FOOTER aggregates work just fine.
0
George Felipe
Top achievements
Rank 1
answered on 10 Nov 2010, 09:53 PM
I'm replying to my own question since I have figured out the issue.

I have identified how fix the problem in two different situations.

When setting a group Aggregate in the code behind... The FIELD ALIAS SHOULD NOT MATCH the name of the FieldName. This will screw things up. So this code is wrong.
GridGroupByField agg = new GridGroupByField();               
agg.FieldName = "Amount"
agg.FieldAlias = "Amount";
agg.Aggregate = GridAggregateFunction.Sum
agg.FormatString = "{0:c}" 
agg.HeaderValueSeparator = ":";

This is right (note FieldAlias is different. Furthermore, do not use special characters in FieldAlias, program will crash):
GridGroupByField agg = new GridGroupByField();               
agg.FieldName = "Amount"
agg.FieldAlias = "TotalAmount";
agg.Aggregate = GridAggregateFunction.Sum
agg.FormatString = "{0:c}" 
agg.HeaderValueSeparator = ":";


Now, for the String based expression, when doing an Aggregate, use a column name that does not exist in your data.

For example, this is wrong:
string var = "SalesRep [Sales Rep], count(RecordNum) RecordNum [Count], Sum(TotalSplit) TotalSplit [Total Split] Group By SalesRep";

This is right:
string var = "SalesRep [Sales Rep], count(RecordNum) MadeUp [Count], Sum(TotalSplit) DoesntExist[Total Split] Group By SalesRep";

Noticed I placed made up column names in the last string.

Hope this information helps.



0
Diogo
Top achievements
Rank 1
answered on 13 Feb 2014, 07:41 PM
It worked for me.
I put a absent FieldAlias to grid group field. The Sum is correct now.
<telerik:GridGroupByField FieldName="Total" FieldAlias="FieldAlias1" HeaderText="Total" Aggregate="Sum"  FormatString="{0:n0}"  ></telerik:GridGroupByField>  

Tks
Tags
Grid
Asked by
Jon Ingersoll
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Jeremy Mann
Top achievements
Rank 1
Pavlina
Telerik team
Fred
Top achievements
Rank 1
George Felipe
Top achievements
Rank 1
Diogo
Top achievements
Rank 1
Share this question
or