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

Main radgrid disappear when ExpandCollapse event fire

2 Answers 20 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Mukul
Top achievements
Rank 1
Mukul asked on 22 Aug 2015, 08:12 AM

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 Answers, 1 is accepted

Sort by
0
Mukul
Top achievements
Rank 1
answered on 22 Aug 2015, 09:19 AM

Hello,

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

so how its resolve

thank

Mukul

 

0
Eyup
Telerik team
answered on 26 Aug 2015, 10:21 AM
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
Tags
General Discussions
Asked by
Mukul
Top achievements
Rank 1
Answers by
Mukul
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or