Telerik Extensions for ASP.NET MVC

This help topic discusses the grouping feature of Telerik Grid for ASP.NET MVC

Important

All Telerik UI components need a ScriptRegistrar component in order to output their JavaScript objects and register their JavaScript files. The ScriptRegistrar component should be defined *after* all other UI components in the page. If you create the components on the client-side and do not use the MVC extensions, you need to manually register all requried JavaScript files. For further information check this help topic (Step 4 - Register Scripts)

Grouping Introduction

Grouping allows the user to group the grid data by certain columns.

To enable grouping use the Groupable method:

CopyView
<%= Html.Telerik().Grid(Model)
        .Name("Grid")
        .Groupable()
%>
This would enable grouping with default configuration.

Grouping Configuration

You can enable grouping conditionally by using the Groupable(Action<(Of <<'(GridGroupingSettingsBuilder>)>>)) method.
CopyC#
<%= Html.Telerik().Grid(Model)
        .Name("Grid")
        .Groupable(grouping => grouping.Enabled((bool)ViewData["enableGrouping"]))
%>
You can define groups from code. The grid will be displayed initially grouped.
CopyC#
<%= Html.Telerik().Grid(Model)
        .Name("Grid")
        .Groupable(grouping => grouping
              .Groups(groups =>
              {
                  //Group by Country
                  groups.Add(c => c.Country);
                  //then by Address
                  groups.Add(c => c.Address);
              })
        )
%>