Telerik is a leading vendor of ASP.NET AJAX, ASP.NET MVC, Silverlight, WinForms and WPF controls and components, as well as .NET Reporting, .NET ORM , .NET CMS, Code Analysis, Mocking, Team Productivity and Automated Testing Tools. Building on its expertise in interface development and Microsoft technologies, Telerik helps customers build applications with unparalleled richness, responsiveness and interactivity. Telerik products help thousands of companies to be more productive and deliver reliable applications under budget and on time.
Version Q1 2012 released 04/11/2012
select

Grid / Footer Aggregates

Example Configuration
new
ProductIDProduct nameUnit priceIn StockUnits On OrderReorder LevelDiscontinued
 
1Chai$18.0039010False
2Chang$19.00174025False
3Aniseed Syrup$10.00137025False
4Chef Anton's Cajun Seasoning$22.005300False
5Chef Anton's Gumbo Mix$21.35000True
6Grandma's Boysenberry Spread$25.00120025False
7Uncle Bob's Organic Dried Pears$30.0015010False
8Northwoods Cranberry Sauce$40.00600False
9Mishi Kobe Niku$97.002900True
10Ikura$31.003100False
11Queso Cabrales$21.00223030False
12Queso Manchego La Pastora$38.008600False
13Konbu$6.002405False
14Tofu$23.253500False
15Genen Shouyu$15.503905False
16Pavlova$17.4529010False
17Alice Mutton$39.00000True
18Carnarvon Tigers$62.504200False
19Teatime Chocolate Biscuits$9.202505False
20Sir Rodney's Marmalade$81.004000False
21Sir Rodney's Scones$10.003405False
22Gustaf's Knäckebröd$21.00104025False
23Tunnbröd$9.0061025False
24Guaraná Fantástica$4.502000True
25NuNuCa Nuß-Nougat-Creme$14.0076030False
26Gumbär Gummibärchen$31.231500False
27Schoggi Schokolade$43.9049030False
28Rössle Sauerkraut$45.602600True
29Thüringer Rostbratwurst$123.79000True
30Nord-Ost Matjeshering$25.8910015False
31Gorgonzola Telino$12.5007020False
32Mascarpone Fabioli$32.0094025False
33Geitost$2.50112020False
34Sasquatch Ale$14.00111015False
35Steeleye Stout$18.0020015False
36Inlagd Sill$19.00112020False
37Gravad lax$26.00115025False
38Côte de Blaye$263.5017015False
39Chartreuse verte$18.006905False
40Boston Crab Meat$18.40123030False
41Jack's New England Clam Chowder$9.6585010False
42Singaporean Hokkien Fried Mee$14.002600True
43Ipoh Coffee$46.00171025False
44Gula Malacca$19.4527015False
45Rogede sild$9.5057015False
46Spegesild$12.009500False
47Zaanse koeken$9.503600False
48Chocolade$12.75157025False
49Maxilaku$20.00106015False
50Valkoinen suklaa$16.2565030False
51Manjimup Dried Apples$53.0020010False
52Filo Mix$7.0038025False
53Perth Pasties$32.80000True
54Tourtière$7.4521010False
55Pâté chinois$24.00115020False
56Gnocchi di nonna Alice$38.00211030False
57Ravioli Angelo$19.5036020False
58Escargots de Bourgogne$13.2562020False
59Raclette Courdavault$55.007900False
60Camembert Pierrot$34.001900False
61Sirop d'érable$28.50113025False
62Tarte au sucre$49.301700False
63Vegie-spread$43.902405False
64Wimmers gute Semmelknödel$33.25228030False
65Louisiana Fiery Hot Pepper Sauce$21.057600False
66Louisiana Hot Spiced Okra$17.00410020False
67Laughing Lumberjack Lager$14.0052010False
68Scottish Longbreads$12.5061015False
69Gudbrandsdalsost$36.0026015False
70Outback Lager$15.00151030False
71Flotemysost$21.502600False
72Mozzarella di Giovanni$34.801400False
73Röd Kaviar$15.0010105False
74Longlife Tofu$10.004205False
75Rhönbräu Klosterbier$7.75125025False
76Lakkalikööri$18.0057020False
77Original Frankfurter grüne Soße$13.0032015False
Click PostBack to see the state of the grid is preserved.

  • There are various cases in which you may want to display results from aggregate functions performed over the columns in the grid in their footer.

    RadGrid provides an intuitive method to define aggregates on a per-column basis from design time and render the results inside the respective column's footer. Aggregate calculations are supported for GridBoundColumns and the rest of the built-in columns which extend from GridBoundColumn (GridDateTimeColumn, GridNumericColumn, GridCalculatedColumn, etc.). In order to specify how the group aggregates will be evaluated, specify in every GridBoundColumn (or the rest of the columns which extend it) the Aggregate property which accepts values from the GridAggregateFunction enumeration. Moreover, you have the ability to set format string for the calculated value that will be displayed in the footer using the FooterAggregateFormatString property of the corresponding column (its default value will match the DataFormatString for the column if set).

    In the Q3 2010 release of Telerik RadControls for ASP.NET AJAX, we have added a handy set of options for selecting aggregate values from RadGrid's header context menu. Setting the RadGrid.EnableHeaderContextAggregatesMenu property to true will enable the aggregate options in the header context menu.

Source Code

C# VB.NET
Show code in new window Demo isolation steps
  • <%@ Page Language="vb" AutoEventWireup="false" CodeFile="DefaultVB.aspx.vb" Inherits="Telerik.GridExamplesCSharp.GeneralFeatures.Aggregates.DefaultVB" %>

    <%@ Register TagPrefix="telerik" Namespace="Telerik.QuickStart" %>
    <%@ Register TagPrefix="telerik" TagName="Header" Src="~/Common/Header.ascx" %>
    <%@ Register TagPrefix="telerik" TagName="HeadTag" Src="~/Common/HeadTag.ascx" %>
    <%@ Register TagPrefix="telerik" TagName="Footer" Src="~/Common/Footer.ascx" %>
    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/tr/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <telerik:HeadTag runat="server" ID="Headtag2"></telerik:HeadTag>
    </head>
    <body class="BODY">
        <form runat="server" id="mainForm" method="post">
            <telerik:Header runat="server" ID="Header1" NavigationLanguage="VB"></telerik:Header>
           <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
            <!-- content start -->
            <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="RadAjaxLoadingPanel1">
                <AjaxSettings>
                    <telerik:AjaxSetting AjaxControlID="RadGrid1">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                    <telerik:AjaxSetting AjaxControlID="EnableAggregatesInHCMCheckBox">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                </AjaxSettings>
            </telerik:RadAjaxManager>

            <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" />

            <telerik:ConfiguratorPanel ID="ConfiguratorPanel1" runat="server" Expanded="true">
                    <div class="title">
    <asp:CheckBox ID="EnableAggregatesInHCMCheckBox" runat="server" AutoPostBack="true"
    OnCheckedChanged="EnableAggregatesInHCMCheckBox_CheckChanged"
    Text="Enable footer aggregates in header context menu" />

                        <img alt="new" src="~/Common/Img/new.gif" runat="server"
                            style="background-color:#002E3D; padding:2px 3px" />
                    </div>
            </telerik:ConfiguratorPanel>
         
            <telerik:RadGrid AutoGenerateColumns="false" ID="RadGrid1"
                DataSourceID="SqlDataSource1" AllowFilteringByColumn="True" ShowFooter="True"
                runat="server" EnableLinqExpressions="false" GridLines="None">
                <PagerStyle Mode="NextPrevAndNumeric" />
                <HeaderStyle Width="150px" />
                <MasterTableView TableLayout="Fixed" OnDataBinding="MasterTableView_DataBinding">
                    <Columns>
                        <telerik:GridNumericColumn Aggregate="Count" DataField="ProductID" HeaderText="ProductID"
                            SortExpression="ProductID" UniqueName="ProductID" HeaderStyle-Width="60px" FilterControlWidth="30px">
                        </telerik:GridNumericColumn>
                        <telerik:GridBoundColumn DataField="ProductName" HeaderText="Product name"
                            SortExpression="ProductName" UniqueName="ProductName">
                        </telerik:GridBoundColumn>
                        <telerik:GridNumericColumn Aggregate="Avg" DataField="UnitPrice" HeaderText="Unit price"
                            SortExpression="UnitPrice" UniqueName="UnitPrice" DataFormatString="{0:C}"
                            HeaderStyle-Width="80px" FilterControlWidth="50px">
                        </telerik:GridNumericColumn>
                        <telerik:GridNumericColumn Aggregate="Sum" DataField="UnitsInStock" HeaderText="In Stock"
                            SortExpression="UnitsInStock" UniqueName="UnitsInStock" HeaderStyle-Width="70px" FilterControlWidth="40px">
                        </telerik:GridNumericColumn>
                        <telerik:GridNumericColumn Aggregate="Max" DataField="UnitsOnOrder" HeaderText="Units On Order"
                            SortExpression="UnitsOnOrder" UniqueName="UnitsOnOrder" HeaderStyle-Width="100px" FilterControlWidth="50px">
                        </telerik:GridNumericColumn>
                        <telerik:GridNumericColumn Aggregate="Min" DataField="ReorderLevel" HeaderText="Reorder Level" FooterText="Min units: "
                            SortExpression="ReorderLevel" UniqueName="ReorderLevel" HeaderStyle-Width="80px" FilterControlWidth="50px">
                        </telerik:GridNumericColumn>
                        <telerik:GridBoundColumn Aggregate="Custom" DataField="Discontinued" FooterText=" "
                            HeaderText="Discontinued" SortExpression="Discontinued" UniqueName="Discontinued"
                            HeaderStyle-Width="70px" AllowFiltering="false">
                        </telerik:GridBoundColumn>
                   </Columns>
                </MasterTableView>
                <ClientSettings>
                  <Scrolling AllowScroll="true" UseStaticHeaders="true" />
                </ClientSettings>
            </telerik:RadGrid>
    <asp:Button ID="Button1" Text="PostBack!" CssClass="button" Style="margin: 10px 22px 10px 0px"
    runat="server"></asp:Button>

            Click PostBack to see the state of the grid is preserved.
            <br />
            <asp:SqlDataSource ID="SqlDataSource1" SelectCommand="SELECT ProductID, ProductName, UnitPrice, UnitsInStock, UnitsOnOrder, ReorderLevel, Discontinued FROM Products" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
                ProviderName="System.Data.SqlClient" runat="server"></asp:SqlDataSource>
            <!-- content end -->
            <telerik:Footer runat="server" ID="Footer1"></telerik:Footer>
        </form>
    </body>
    </html>

Get more than expected!

Take your time to truly experience the power of RadControls for ASP.NET AJAX with a free 60-day trial backed up by Telerik’s unlimited dedicated support.

Download your RadControls for ASP.NET AJAX trial and jumpstart your development with the available Getting Started resources.

If you have any questions, do not hesitate to contact us at sales@telerik.com.

Copyright 2002-2012 © Telerik. All right reserved
Telerik Inc, 201 Jones Rd, Waltham, MA 02451