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

Multiple Grids inside NestedViewTemplate - PreRender event only firing on first instance of child grid

0 Answers 133 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 16 May 2018, 07:37 PM

I have a RadGrid with a NestedViewTemplate that contains a RadTabStrip and RadMultiPage. On each RadPageView there is another RadGrid that displays a sub-set of items related to the id of the item that is being expanded.

In addition, the columns of all RadGrids on the page are hidden/displayed according to a corresponding List<string> variable containing the column names that I want to be displayed. The columns are hidden in the grid_PreRender event IF their uniqueName is NOT in the list of column names.

I have two main problems:

The first problem is that while this _PreRender hiding of columns is working fine in the parent grid and any grid found in the first expanded row, any grids found in other expanded rows do not seem to be experiencing the PreRender event and therefore the columns that should be hidden are being displayed.

The second problem is that I need to be able to show/hide the columns on the client side when the user clicks on the corresponding checkbox in a RadTreeView containing all the columns of all the grids on the page. I have managed to get this working fine for the main grid and the first expanded row grids. The issue is that if multiple rows of the main grid are expanded then many instances of a child grid are displayed and I need client side code that can target all the displayed child grids and hide/show the selected column.

<telerik:RadGrid ID="gvEventListing" runat="server" PageSize="10" Skin="Silk"
AllowSorting="True" AllowMultiRowSelection="True" AllowPaging="True" AllowCustomPaging="True" ShowGroupPanel="True" OnPreRender="gvEventListing_PreRender"
AutoGenerateColumns="False" GridLines="none" OnGroupsChanging="gvEventListing_GroupsChanging" OnItemCommand="gvEventListing_ItemCommand"
OnItemCreated="gvEventListing_ItemCreated" OnNeedDataSource="gvEventListing_OnNeedDataSource" OnItemDataBound="gvEventListing_ItemDataBound">
<PagerStyle Mode="NextPrevNumericAndAdvanced"></PagerStyle>
<MasterTableView DataKeyNames="IncidentSID,FacilityID" AllowMultiColumnSorting="True">
    <NestedViewTemplate>
        <asp:Panel runat="server" ID="InnerContainer" CssClass="viewWrap" Visible="false">
            <telerik:RadTabStrip Skin="MetroTouch" runat="server" ID="TabStip1" MultiPageID="Multipage1" SelectedIndex="0" OnClientTabSelecting="OnClientTabSelectingHandler">
                <Tabs>
                    <telerik:RadTab runat="server" Text="Participants" PageViewID="PageView1">
                    </telerik:RadTab>
                    <telerik:RadTab runat="server" Text="Comments" PageViewID="PageView2">
                    </telerik:RadTab>
                    <telerik:RadTab runat="server" Text="Phase Progression" PageViewID="PageView3">
                    </telerik:RadTab>
                    <telerik:RadTab runat="server" Text="Notifications" PageViewID="PageView4">
                    </telerik:RadTab>
                    <telerik:RadTab runat="server" Text="Corrective Actions" PageViewID="PageView5">
                    </telerik:RadTab>
                </Tabs>
            </telerik:RadTabStrip>
            <telerik:RadMultiPage runat="server" ID="Multipage1" SelectedIndex="0" RenderSelectedPageOnly="False">                           
                <telerik:RadPageView runat="server" ID="PageView1" Width="100%">
                    <telerik:RadGrid runat="server" ID="gvParticipants" ShowFooter="false" Skin="Silk" OnPreRender="gvParticipants_PreRender" CssClass="gvParticipants"
                    AllowSorting="true" EnableLinqExpressions="false" OnNeedDataSource="gvParticipants_OnNeedDataSource">
                        <MasterTableView ShowHeader="true" AutoGenerateColumns="False" AllowPaging="true"
                        DataKeyNames="ParticipantSID" PageSize="7" HierarchyLoadMode="ServerOnDemand">
                            <Columns>
                                <telerik:GridBoundColumn SortExpression="PersonID" HeaderText="PersonID" HeaderButtonType="TextButton"
                                DataField="PersonID" UniqueName="PersonID"></telerik:GridBoundColumn>
                                <telerik:GridBoundColumn SortExpression="ParticipationTypeLabel" HeaderText="Participation" HeaderButtonType="TextButton"
                                DataField="ParticipationTypeLabel" UniqueName="ParticipationTypeLabel"></telerik:GridBoundColumn>
                                <telerik:GridBoundColumn SortExpression="Name" HeaderText="Name" HeaderButtonType="TextButton"
                                DataField="Name" UniqueName="Name"></telerik:GridBoundColumn>
                                <telerik:GridBoundColumn SortExpression="Identifier" HeaderText="Rec#/Emp ID" HeaderButtonType="TextButton"
                                DataField="Identifier" UniqueName="Identifier"></telerik:GridBoundColumn>
                            </Columns>
                        </MasterTableView>
                        <ClientSettings AllowDragToGroup="true">
                            <Scrolling AllowScroll="true" ScrollHeight="" />
                        </ClientSettings>
                    <PagerStyle PageButtonCount="3" Mode="NextPrevAndNumeric" ShowPagerText="false" />
                    </telerik:RadGrid>
                </telerik:RadPageView>
protected void gvParticipants_PreRender(object sender, EventArgs e)
{      
    GridNestedViewItem item = (GridNestedViewItem)gvEventListing.MasterTableView.GetItems(GridItemType.NestedView)[0];
    RadGrid grid = (RadGrid)item.FindControl("gvParticipants");
    foreach (GridColumn col in grid.Columns)
    {
        if (!_fields_participants.Contains(col.UniqueName))
        {
            col.Display = false;
        }
    }
}

No answers yet. Maybe you can help?

Tags
Grid
Asked by
Michael
Top achievements
Rank 1
Share this question
or