Unit price: 9.65
Unit price: 10.00
Unit price: 12.00
Unit price: 12.50
Unit price: 12.75
Unit price: 13.00
Unit price: 13.25
In addition to displaying summaries/results from aggregates in the group header, RadGrid exposes group footers feature which provides the option to render footer under each group in the grid. The type of this footer item is GridGroupFooterItem. To enable this functionality merely set the ShowGroupFooter property of the respective GridTableView instance to true (its default value is false).
RadGrid also gives you the opportunity to retain the visibility of the group footers when their corresponding group header row is collapsed. In order to switch on this feature, just set the GroupingSettings.RetainGroupFooterVisibilityproperty to true.
The group footers are most commonly used to visualize calculations from aggregate functions within the scope of the current group. Furthermore, with nested groups you will have group footer for each inner group along with one for the main group. Aggregate calculations are supported for GridBoundColumns, GridCalculatedColumns and GridTemplateColumns.
In order to specify how the group aggregates will be evaluated, specify in every GridBoundColumn/GridCalculatedColumn/GridTemplateColumn the Aggregate property which accepts values from the GridAggregateFunction enumeration. RadGrid will calculate aggregates over the entire data source and will respect the filter expression applied (if present).
<%@ Page Language="vb" AutoEventWireup="true" CodeFile="DefaultVB.aspx.vb" Inherits="Telerik.GridExamplesVBNET.GroupBy.GroupFooter.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:ConfiguratorPanel ID="ConfiguratorPanel1" runat="server" Expanded="true"> <div class="title" style="font-size: 16px"> Displaying RadGrid's group footers:</div> <span style="font-size: 14px">Switch group load mode:</span> <asp:RadioButtonList AutoPostBack="true" ID="RadioButtonList1" OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged" runat="server"> <asp:ListItem Text="Server"> </asp:ListItem> <asp:ListItem Text="Client"> </asp:ListItem> </asp:RadioButtonList> <asp:CheckBox ID="chkKeepGroupFootersVisible" AutoPostBack="true" Text="Retain group footers' visibility" OnCheckedChanged="chkKeepGroupFootersVisible_CheckedChanged" runat="server" /> <br /> <br /> </telerik:ConfiguratorPanel> <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="RadGrid1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" /> </UpdatedControls> </telerik:AjaxSetting> <telerik:AjaxSetting AjaxControlID="RadioButtonList1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" /> <telerik:AjaxUpdatedControl ControlID="RadioButtonList1" /> </UpdatedControls> </telerik:AjaxSetting> <telerik:AjaxSetting AjaxControlID="chkKeepGroupFootersVisible"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" /> <telerik:AjaxUpdatedControl ControlID="chkKeepGroupFootersVisible" /> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings> </telerik:RadAjaxManager> <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" /> <telerik:RadGrid ShowGroupPanel="true" AutoGenerateColumns="false" ID="RadGrid1" DataSourceID="SqlDataSource1" AllowFilteringByColumn="True" AllowSorting="True" ShowFooter="True" runat="server" GridLines="None" AllowPaging="true" EnableLinqExpressions="false"> <PagerStyle Mode="NextPrevAndNumeric" /> <MasterTableView ShowGroupFooter="true" AllowMultiColumnSorting="true"> <Columns> <telerik:GridBoundColumn Aggregate="Count" DataField="ProductID" HeaderText="Product ID" FooterText="Total products: "> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="ProductName" HeaderText="Product name" SortExpression="ProductName" UniqueName="ProductName"> </telerik:GridBoundColumn> <telerik:GridBoundColumn Aggregate="Sum" DataField="UnitPrice" HeaderText="Unit price" FooterText="Total price: "> </telerik:GridBoundColumn> <telerik:GridTemplateColumn DataField="UnitsInStock" HeaderText="Units in stock" FooterText="All units in stock: " UniqueName="UnitsInStock" GroupByExpression="UnitsInStock Group By UnitsInStock" Aggregate="Sum"> <ItemTemplate> <asp:Label ID="lblUnitsInStock" runat="server" Text='<%#Eval("UnitsInStock") %>'> </asp:Label> </ItemTemplate> <EditItemTemplate> <telerik:RadNumericTextBox ID="txtUnitsInStock" runat="server" Text='<%#Bind("UnitsInStock") %>'> </telerik:RadNumericTextBox> </EditItemTemplate> </telerik:GridTemplateColumn> <telerik:GridCalculatedColumn HeaderText="Total Price" UniqueName="TotalPrice" DataType="System.Double" DataFields="UnitPrice, UnitsInStock" Expression="{0}*{1}" FooterText="Total : " Aggregate="Sum" /> </Columns> <GroupByExpressions> <telerik:GridGroupByExpression> <GroupByFields> <telerik:GridGroupByField FieldName="UnitPrice" /> </GroupByFields> <SelectFields> <telerik:GridGroupByField FieldName="UnitPrice" HeaderText="Unit price" /> </SelectFields> </telerik:GridGroupByExpression> </GroupByExpressions> </MasterTableView> <ClientSettings AllowDragToGroup="true" /> <GroupingSettings ShowUnGroupButton="true" /> </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. <asp:SqlDataSource ID="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="SELECT * FROM Products Where UnitPrice > 9.50" runat="server"> </asp:SqlDataSource> <!-- content end --> <telerik:Footer runat="server" ID="Footer1"></telerik:Footer> </form></body></html>
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.