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

RadGrid grouping with RadClientDataSource

Country  ContactTitle  
CountryContact TitleContact NameCompany Name
  
Page size:
 13 items in 2 pages
      
      
      
      
      
      
      
      
      
      
      
      
  • NoFilter
  • Contains
  • DoesNotContain
  • StartsWith
  • EndsWith
  • EqualTo
  • NotEqualTo
  • GreaterThan
  • LessThan
  • GreaterThanOrEqualTo
  • LessThanOrEqualTo
  • Between
  • NotBetween
  • IsEmpty
  • NotIsEmpty
  • IsNull
  • NotIsNull
  • Custom

With RadGrid data-bound to a RadClientDataSource you can have an entirely client-side grouping functionality and avoid unnecessary postbacks to the server. Integrating those two controls allows fast grouping to be performed directly on client-side, without losing any of the supported with server-side grouping features (like adding, removing or rearranging groups, collapsing, expanding, etc.).

For enabling client-side grouping, you just need to have a properly configured RadClientDataSource control and set the ClientDataSourceID property of RadGrid. In the same manner as with server-side grouping, you can have predefined groups in GroupByExpressions (by adding data fields in SelectFields and/or GroupByFields within GridGroupByExpression) or allow the user to drag and drop columns to the GroupPanel.

  • DefaultVB.aspx
<%@ Page Language="vb" AutoEventWireup="true" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<%@ Register TagPrefix="qsf" Namespace="Telerik.QuickStart" %>

<!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:RadClientDataSource ID="RadClientDataSource1" runat="server">
        <DataSource>
            <WebServiceDataSourceSettings ServiceType="OData">
                <Select Url="https://demos.telerik.com/kendo-ui/service/Northwind.svc/Customers" DataType="JSON" />
            </WebServiceDataSourceSettings>
        </DataSource>
    </telerik:RadClientDataSource>
    <div class="demo-container no-bg">
        <telerik:RadGrid RenderMode="Lightweight" ID="RadGrid1" ClientDataSourceID="RadClientDataSource1" runat="server" AllowMultiRowSelection="true"
            AllowSorting="True" AllowPaging="True" PageSize="12" ShowGroupPanel="True" AutoGenerateColumns="false" AllowFilteringByColumn="true">
            <GroupingSettings ShowUnGroupButton="true"></GroupingSettings>
            <MasterTableView GroupLoadMode="Client" TableLayout="Fixed" EnableGroupsExpandAll="true">
                <GroupByExpressions>
                    <telerik:GridGroupByExpression>
                        <SelectFields>
                            <telerik:GridGroupByField FieldAlias="Country" FieldName="Country"></telerik:GridGroupByField>
                        </SelectFields>
                        <GroupByFields>
                            <telerik:GridGroupByField FieldName="Country"></telerik:GridGroupByField>
                        </GroupByFields>
                    </telerik:GridGroupByExpression>
                    <telerik:GridGroupByExpression>
                        <SelectFields>
                            <telerik:GridGroupByField FieldAlias="ContactTitle" FieldName="ContactTitle"></telerik:GridGroupByField>
                        </SelectFields>
                        <GroupByFields>
                            <telerik:GridGroupByField FieldName="ContactTitle"></telerik:GridGroupByField>
                        </GroupByFields>
                    </telerik:GridGroupByExpression>
                </GroupByExpressions>
                <Columns>
                    <telerik:GridBoundColumn DataField="Country" HeaderText="Country"></telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="ContactTitle" HeaderText="Contact Title"></telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="ContactName" HeaderText="Contact Name"></telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="CompanyName" HeaderText="Company Name"></telerik:GridBoundColumn>
                </Columns>
            </MasterTableView>
            <GroupingSettings ShowUnGroupButton="true" />
            <ClientSettings AllowDragToGroup="true">
                <Selecting AllowRowSelect="true" />
            </ClientSettings>
        </telerik:RadGrid>
    </div>
    </form>
</body>
</html>

Support & Learning Resources

Find Assistance