Multiple Group Header in RadGrid

2 posts, 0 answers
  1. Sumith
    Sumith avatar
    1 posts
    Member since:
    Jan 2012

    Posted 21 Jan 2013 Link to this post

    Hi Experts,

    I have created rad grid with  multiple group header and added the check box in  first grouping header (BATCH_ID).So i want to do,
    when i check the   check box in first grouping header then to be selected (highlighted) the grid items belong to second group header (ITEM_NAME)



    Grouping  at Design Level
    <GroupByExpressions>
    <!-- First Grouping Header -->
                            <telerik:GridGroupByExpression>
                                <SelectFields>
                                    <telerik:GridGroupByField FieldAlias="BATCH_ID" FieldName="BATCH_ID" HeaderValueSeparator=" : " />
                                </SelectFields>
                                <GroupByFields>
                                    <telerik:GridGroupByField FieldName="BATCH_ID" SortOrder="Ascending" />
                                </GroupByFields>
                            </telerik:GridGroupByExpression>
    <!-- Second Grouping Header -->
                            <telerik:GridGroupByExpression>
                                <SelectFields>
                                    <telerik:GridGroupByField FieldAlias="Name" FieldName="EMP_DISPLAY_NAME" HeaderValueSeparator=" : " />
                                </SelectFields>
                                <GroupByFields>
                                    <telerik:GridGroupByField FieldName="ITEM_NAME" SortOrder="Ascending" />
                                </GroupByFields>
                            </telerik:GridGroupByExpression
    </GroupByExpressions>

             Create Header control at run time
    Private Sub CreateHeaderControls(ByVal e As GridItemEventArgs)
            If TypeOf e.Item Is GridGroupHeaderItem Then
                Dim item As GridGroupHeaderItem = e.Item
                If IsNumeric(item.GroupIndex.ToString()) Then
                    item.DataCell.Controls.Clear()
                    Dim check As New CheckBox()
                    check.AutoPostBack = True
                    check.ID = "CheckAll"
                    AddHandler check.CheckedChanged, AddressOf check_CheckedChanged
                    item.DataCell.Controls.Add(check)
                End If
            End If
        End Sub


    Thanks
  2. Angel Petrov
    Admin
    Angel Petrov avatar
    1153 posts

    Posted 24 Jan 2013 Link to this post

    Hello Sumith,

    In order to implement such functionality you would have to use the GroupIndex. In the event handler you can do something like this:

    Protected Sub check_CheckedChanged(sender As Object, e As System.EventArgs)
            Dim CheckBox = CType(sender, CheckBox)
            'Extract the groupIndex like shown below
            Dim groupIndex As String = DirectCast(CheckBox.NamingContainer, Telerik.Web.UI.GridGroupHeaderItem).GroupIndex
            'Iterate through the items in the grid and according to their GroupIndex select them
        End Sub

    Please note that you would have implement logic that compares the GroupIndex of the item with the GroupIndex of the header and selects the items in the grid that match the criteria.

    Kind regards,
    Angel Petrov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top