New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

Grouping

Received  FolderName  
 ReceivedFromFolder nameSize
123
 Item 21 to 40 of 52
Page:
of 3 GoPage size:
Received from date: Thursday, March 25, 2010
FolderName: Inbox
   3/25/2010CThomas@web.comInbox5
   3/25/2010JDavis@web.comInbox7
   3/25/2010SSaylor@web.comInbox9
   3/25/2010HIsaman@web.comInbox54
   3/25/2010SSwartzbaugh@web.comInbox65
   3/25/2010OGertraht@web.comInbox4
FolderName: Sent Items
   3/25/2010MWhittier@web.comSent Items2
Received from date: Wednesday, March 24, 2010
FolderName: Inbox
   3/24/2010JReade@web.comInbox2
   3/24/2010BChapman@web.comInbox7
   3/24/2010SWilliams@web.comInbox658
   3/24/2010JButtermore@web.comInbox65
   3/24/2010KWilliamson@web.comInbox2
FolderName: Sent Items
   3/24/2010KHoenshell@web.comSent Items34
Received from date: Tuesday, March 23, 2010
FolderName: Inbox
   3/23/2010admin13@telerik.comInbox65
   3/23/2010EChappel@web.comInbox89
   3/23/2010KerriButler@web.comInbox23
   3/23/2010admin12@telerik.comInbox645
   3/23/2010ParrisWood@web.comInbox2
   3/23/2010MBlackburn@web.comInbox34
   3/23/2010PMilne@web.comInbox6
This example demonstrates how GroupByExpressions can be used in Telerik RadGrid:
Creating group-by expressions - GridGroupByField Properties:
  • FieldName: name of any field from the DataSource
  • FieldAlias: alias string. This cannot contain blanks or other reserved symbols like ',', '.' etc.
  • Aggregate: any of - min, max, sum, count, last, first etc (the same as in GridAggregateFunction enumeration)
  • SortOrder: acs or desc - the sort order of the grouped items
  • HeaderText: specifies the name to use for the field when it appears in the group header and in the group panel. This property lets you specify a field name that includes blanks or reserved characters. This property is only used for fields in the SelectFields collection. Meaningful for items from the SelectFields collection only.
  • FormatString: specifies a format string for formatting field values when they appear in the group header. This property is only used for fields in the SelectFields collection. Meaningful for items from the SelectFields collection only.
  • HeaderValueSeparator: specifies a string that appears in the group header between the header text and the value (or aggregated value). This property is only used for fields in the SelectFields collection. Meaningful for items from the SelectFields collection only.
Note that grouping is not supported with simple data-binding (calling DataBind()). See the Simple data binding demo from the Populating with data section for more info about the limitations of this binding mode.
  • DefaultVB.aspx
<%@ Page Language="vb"  %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head runat="server">
    <title>Telerik ASP.NET Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" UpdateInitiatorPanelsOnly="true">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1"></telerik:AjaxUpdatedControl>
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
    </telerik:RadAjaxLoadingPanel>
    <div class="demo-container no-bg">
        <telerik:RadGrid RenderMode="Lightweight" ID="RadGrid1" DataSourceID="SqlDataSource1" runat="server" PageSize="20"
            AllowSorting="True" AllowMultiRowSelection="True" AllowPaging="True" ShowGroupPanel="True"
            AutoGenerateColumns="False" GridLines="none">
            <PagerStyle Mode="NextPrevNumericAndAdvanced"></PagerStyle>
            <MasterTableView Width="100%">
                <GroupByExpressions>
                    <telerik:GridGroupByExpression>
                        <SelectFields>
                            <telerik:GridGroupByField FieldAlias="Received" FieldName="Received" FormatString="{0:D}"
                                HeaderValueSeparator=" from date: "></telerik:GridGroupByField>
                        </SelectFields>
                        <GroupByFields>
                            <telerik:GridGroupByField FieldName="Received" SortOrder="Descending"></telerik:GridGroupByField>
                        </GroupByFields>
                    </telerik:GridGroupByExpression>
                    <telerik:GridGroupByExpression>
                        <SelectFields>
                            <telerik:GridGroupByField FieldAlias="FolderName" FieldName="FolderName"></telerik:GridGroupByField>
                        </SelectFields>
                        <GroupByFields>
                            <telerik:GridGroupByField FieldName="FolderName"></telerik:GridGroupByField>
                        </GroupByFields>
                    </telerik:GridGroupByExpression>
                </GroupByExpressions>
                <Columns>
                    <telerik:GridBoundColumn SortExpression="Received" HeaderText="Received" HeaderButtonType="TextButton"
                        DataField="Received" DataFormatString="{0:d}">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn SortExpression="From" HeaderText="From" HeaderButtonType="TextButton"
                        DataField="From">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn SortExpression="FolderName" HeaderText="Folder name" HeaderButtonType="TextButton"
                        DataField="FolderName">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn SortExpression="Size" HeaderText="Size" HeaderButtonType="TextButton"
                        DataField="Size">
                    </telerik:GridBoundColumn>
                </Columns>
            </MasterTableView>
            <ClientSettings ReorderColumnsOnClient="True" AllowDragToGroup="True" AllowColumnsReorder="True">
                <Selecting AllowRowSelect="True"></Selecting>
                <Resizing AllowRowResize="True" AllowColumnResize="True" EnableRealTimeResize="True"
                    ResizeGridOnColumnResize="False"></Resizing>
            </ClientSettings>
            <GroupingSettings ShowUnGroupButton="true"></GroupingSettings>
        </telerik:RadGrid>
    </div>
    <asp:SqlDataSource ID="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:TelerikConnectionString %>"
        ProviderName="System.Data.SqlClient" SelectCommand="SELECT * FROM Mails" runat="server"></asp:SqlDataSource>
    </form>
</body>
</html>

Support & Learning Resources

Find Assistance