Main radgrid disappear when ExpandCollapse event fire

3 posts, 0 answers
  1. Mukul
    Mukul avatar
    12 posts
    Member since:
    Jan 2015

    Posted 22 Aug 2015 Link to this post

    Hello,

    I am using two nested grid inside main radgrid ,its working fine when expand the nested grid but when  collapse event fire then main grid disappear

    i am not identified how to handle its on Pre_render or itemCommand event below is my Code

     

       <telerik:RadGrid ID="gvJobDeatail" runat="server" GridLines="None" AutoGenerateColumns="false"
                                AllowPaging="true" AllowSorting="true" AllowAutomaticUpdates="true" ShowStatusBar="true"
                                PageSize="5" OnNeedDataSource="BindDataGrid_OnNeedDataSource" OnItemCommand="gvJobDetails_onItemCommand"
                                OnPreRender="gvJobDetails_PreRender" OnItemCreated="RadGrid_ItemCreated">
                                <%--OnItemCreated="gvJobDetails_ItemCreatd">--%>
                                <PagerStyle Mode="NextPrevAndNumeric" />
                                <MasterTableView DataKeyNames="INSTANCEID" ShowFooter="true" TableLayout="Fixed">
                                    <Columns>
                                        <telerik:GridBoundColumn SortExpression="INSTANCEID" DataField="INSTANCEID" HeaderText="Instance Id">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn SortExpression="JOBNAME" DataField="JOBNAME" HeaderText="Job Name">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn SortExpression="STRATTIME" DataField="STRATTIME" HeaderText="Start Date and Time">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn SortExpression="ENDTIME" DataField="ENDTIME" HeaderText="End Date and Time">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn SortExpression="STATUS" DataField="STATUS" HeaderText="Status">
                                        </telerik:GridBoundColumn>
                                    </Columns>
                                    <NestedViewTemplate>
                                        <asp:Panel ID="pnlDetails" runat="server" Visible="false">
                                            <table width="50%">
                                                <tr>
                                                    <td>
                                                        <asp:Label ID="lblFormatted" runat="server" Text="File Detail:For Formatted Offload type"
                                                            CssClass="normalbold"></asp:Label>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <telerik:RadGrid ID="gvInstanceDetails" runat="server" AllowPaging="true" ShowStatusBar="true"
                                                            Width="1050px" Height="250px" AutoGenerateColumns="False" AutoExpandGroups="false"
                                                            PageSize="5" AllowMultiRowSelection="false" GridLines="None" AllowSorting="true"
                                                            OnNeedDataSource="gvInstanceDetails_NeedDataSource">
                                                            <%--  >--%>
                                                            <PagerStyle Mode="NextPrevAndNumeric" PagerTextFormat="" />
                                                            <MasterTableView AllowMultiColumnSorting="True">
                                                                <Columns>
                                                                    <telerik:GridBoundColumn DataField="FileRaeted" HeaderText="Files Rated" SortExpression="FileRaeted">
                                                                    </telerik:GridBoundColumn>
                                                                    <telerik:GridBoundColumn DataField="ip" HeaderText="Files in FTP " SortExpression="ip">
                                                                    </telerik:GridBoundColumn>
                                                                    <telerik:GridBoundColumn DataField="FileFailure" HeaderText="Files re-tried sending to FTP"
                                                                        SortExpression="FileFailure">
                                                                    </telerik:GridBoundColumn>
                                                                </Columns>
                                                            </MasterTableView>
                                                            <ClientSettings EnableRowHoverStyle="true" EnablePostBackOnRowClick="false">
                                                                <Selecting AllowRowSelect="true" EnableDragToSelectRows="false" />
                                                                <Scrolling AllowScroll="true" UseStaticHeaders="true" ScrollHeight="" />
                                                            </ClientSettings>
                                                        </telerik:RadGrid>
                                                    </td>
                                                </tr>
                                            </table>
                                        </asp:Panel>
                                        <asp:Panel ID="pnlRawDetail" runat="server" Visible="false">
                                            <table>
                                                <tr>
                                                    <td>
                                                        <asp:Label ID="lblRaw" runat="server" Text="File Detail:For Raw Offload type" CssClass="normalbold"></asp:Label>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <telerik:RadGrid ID="gvRawDetails" runat="server" AllowPaging="true" ShowStatusBar="true"
                                                            Width="1050px" Height="250px" AutoGenerateColumns="False" AutoExpandGroups="false"
                                                            PageSize="5" AllowMultiRowSelection="false" GridLines="None" AllowSorting="true"
                                                            OnNeedDataSource="gvRawDetails_NeedDataSource">
                                                            <%--  >--%>
                                                            <PagerStyle Mode="NextPrevAndNumeric" PagerTextFormat="" />
                                                            <MasterTableView AllowMultiColumnSorting="True">
                                                                <Columns>
                                                                    <telerik:GridBoundColumn DataField="FileRaeted" HeaderText="Files in Queue" SortExpression="FileRaeted">
                                                                    </telerik:GridBoundColumn>
                                                                    <telerik:GridBoundColumn DataField="ip" HeaderText="Files sent to FTP " SortExpression="ip">
                                                                    </telerik:GridBoundColumn>
                                                                    <telerik:GridBoundColumn DataField="FileFailure" HeaderText="Files re-tried sending to FTP"
                                                                        SortExpression="FileFailure">
                                                                    </telerik:GridBoundColumn>
                                                                </Columns>
                                                            </MasterTableView>
                                                            <ClientSettings EnableRowHoverStyle="true" EnablePostBackOnRowClick="false">
                                                                <Selecting AllowRowSelect="true" EnableDragToSelectRows="false" />
                                                                <Scrolling AllowScroll="true" UseStaticHeaders="true" ScrollHeight="" />
                                                            </ClientSettings>
                                                        </telerik:RadGrid>
                                                    </td>
                                                </tr>
                                            </table>
                                        </asp:Panel>
                                    </NestedViewTemplate>
                                </MasterTableView>
                                <ClientSettings EnableRowHoverStyle="true">
                                    <Scrolling UseStaticHeaders="true" AllowScroll="true" />
                                    <Scrolling />
                                </ClientSettings>
                            </telerik:RadGrid>
                        </td>
                    </tr>
                </table>
            </div>
        </asp:Panel>

     

    And code behind for radgrid

     

      protected void gvJobDetails_onItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
            {
                DateTime jobDate;
                DateTime.TryParse(txtSelectDate.Text, out jobDate);

                int jobNumber = Convert.ToInt32(ddlSelectJob.SelectedItem.Value);
                string offloadType = ddlOffloadType.SelectedItem.Text;
                if (e.CommandName == "ExpandCollapse" && e.Item is GridDataItem)
                {
                    GridDataItem parentItem = e.Item as GridDataItem;
                    string instanceId = parentItem["INSTANCEID"].Text.ToString();
                    // txtToFtp.Text = Convert.ToString(instanceId);
                    lblInstance.Text = Convert.ToString(instanceId);
                    RadGrid rg = parentItem.ChildItem.FindControl("gvInstanceDetails") as RadGrid;
                    rg.Rebind();
                    RadGrid gvRaw = parentItem.ChildItem.FindControl("gvRawDetails") as RadGrid;
                    gvRaw.Rebind();
                    

                }
                if (e.CommandName == RadGrid.ExpandCollapseCommandName && e.Item is GridDataItem)
                {
                    if (ddlOffloadType.SelectedItem.Text == "Formatted Offload")
                    {
                    ((GridDataItem)e.Item).ChildItem.FindControl("pnlDetails").Visible = !e.Item.Expanded;
                    }
                    if (ddlOffloadType.SelectedItem.Text == "Raw Offload")
                    {
                        ((GridDataItem)e.Item).ChildItem.FindControl("pnlRawDetail").Visible = !e.Item.Expanded;
                    }

                    foreach (GridItem item in e.Item.OwnerTableView.Items)
                    {
                        if (item.Expanded && item != e.Item)
                        {
                            item.Expanded = false;
                        }
                    }
                }
              
            }
            protected void Page_PreRender(object sender, EventArgs e)
            {

                // gvJobDeatail.Rebind();

            }
            protected void RadGrid_ItemCreated(object sender, GridItemEventArgs e)
            {
                if (e.Item is GridNestedViewItem)
                {
                    (e.Item.FindControl("gvInstanceDetails") as RadGrid).NeedDataSource += new GridNeedDataSourceEventHandler(gvInstanceDetails_NeedDataSource);
                    (e.Item.FindControl("gvRawDetails") as RadGrid).NeedDataSource += new GridNeedDataSourceEventHandler(gvInstanceDetails_NeedDataSource);
                }
            }
            protected void gvJobDetails_PreRender(object sender, EventArgs e)
            {
                HideExpandColumnRecursive(gvJobDeatail.MasterTableView);
            }
            public void HideExpandColumnRecursive(GridTableView tableView)
            {
                GridItem[] nestedViewItems = tableView.GetItems(GridItemType.NestedView);
                foreach (GridNestedViewItem nestedViewItem in nestedViewItems)
                {
                    foreach (GridTableView nestedView in nestedViewItem.NestedTableViews)
                    {
                        if (nestedView.Items.Count == 0)
                        {
                            nestedView.ParentItem.Expanded = false;
                        }
                        else
                        {
                            nestedView.ParentItem.Expanded = true;
                        }
                    }
                }
            }

  2. Mukul
    Mukul avatar
    12 posts
    Member since:
    Jan 2015

    Posted 22 Aug 2015 in reply to Mukul Link to this post

    Hello,

    i resolve the issue,for visible =true main radgrid   but its disappear on inner grid paging 

    so how its resolve

    thank

    Mukul

     

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Eyup
    Admin
    Eyup avatar
    3007 posts

    Posted 26 Aug 2015 Link to this post

    Hi Mukul,

    You can examine the sample provided in the following post for a practical implementation of binding inner grids within the NestedViewTemplate:
    http://www.telerik.com/forums/how-to-access-datalist-from-inside-a-nestedviewtemplate#Yp9xRNIG3Um-oPcB1t666A

    Hope this helps.

    Regards,
    Eyup
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top