This is a migrated thread and some comments may be shown as answers.

Access items in GroupHeaderTemplate

1 Answer 22 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Allan
Top achievements
Rank 1
Allan asked on 16 May 2014, 09:15 PM
I have create a table in the GroupHeaderTemplate.

<GroupHeaderTemplate>
                <table style="padding: 0px; margin: 0px; width: 100%; border-collapse: collapse;" id="tbl_GroupHeader">
                    <tr>
                        <td style="width: 10px; text-align: center;">
                              
                        </td>
                        <td style="width: 40px; text-align: center;">
                            <asp:Label runat="server" ID="Label1" Text="Account"></asp:Label>
                        </td>
                        <td style="text-align: center;">
                            <asp:Label runat="server" ID="Label2" Text="Description"></asp:Label>
                        </td>
                        <td style="width: 60px; text-align: center;">
                            <asp:Label runat="server" ID="Label3" Text="Date"></asp:Label>
                        </td>
                        <td style="width: 60px; text-align: center;">
                            <asp:Label runat="server" ID="Label4" Text="Entity ID"></asp:Label>
                        </td>
                        <td style="width: 150px; text-align: center;">
                            <asp:Label runat="server" ID="Label5" Text="MemberName"></asp:Label>
                        </td>
                        <td style="width: 70px; text-align: center;">
                            <asp:Label runat="server" ID="Label6" Text="Debit"></asp:Label>
                        </td>
                        <td style="width: 70px; text-align: center;">
                            <asp:Label runat="server" ID="Label7" Text="Credit"></asp:Label>
                        </td>
                    </tr>
                </table>
            </GroupHeaderTemplate>


I would like to access the table to hide it if the groupd is collapsed like:


Protected Sub rgd_JournalEntries_ItemCommand(sender As Object, e As Telerik.Web.UI.GridCommandEventArgs) Handles rgd_JournalEntries.ItemCommand
     If e.CommandName = "ExpandCollapse" Then
         If e.Item.Expanded Then
             For Each item As GridGroupHeaderItem In rgd_JournalEntries.MasterTableView.GetItems(GridItemType.GroupHeader)
                 TryCast(item.FindControl("tbl_GroupHeader"), Table).Visible = True
             Next
         Else
             For Each item As GridGroupHeaderItem In rgd_JournalEntries.MasterTableView.GetItems(GridItemType.GroupHeader)
                 TryCast(item.FindControl("tbl_GroupHeader"), Table).Visible = False
            Next
         End If
     End If
 
End Sub


Or just hide the GroupHeaderTemplate itself if the group is collapsed

Thank you for any help.

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 17 May 2014, 06:17 AM
Hi Allan,

I guess you want to hide the table when the group is collapsed. Please set runat="server" for the table and access it as follows:

ASPX:
<table runat="server" id="tbl_GroupHeader" . . .>

VB:
Protected Sub RadGrid1_ItemCommand(sender As Object, e As GridCommandEventArgs)
    If e.CommandName = "ExpandCollapse" Then
        If TypeOf e.Item Is GridGroupHeaderItem Then
            Dim item As GridGroupHeaderItem = DirectCast(e.Item, GridGroupHeaderItem)
            If e.Item.Expanded Then
                item.FindControl("tbl_GroupHeader").Visible = False
            Else
                item.FindControl("tbl_GroupHeader").Visible = True
            End If
        End If
    End If
End Sub

Thanks,
Princy
Tags
Grid
Asked by
Allan
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Share this question
or