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

Issue in displaying radgrid inside radgrid

2 Answers 22 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sudhakar
Top achievements
Rank 1
Sudhakar asked on 27 Aug 2014, 12:25 PM
Hi,
I have a radgrid displayed on the screen.it has some rows.

when i expand each row i need to present with three tabs inside that grid.
once i click on the each tab i need to display another  grid with some other records.How to achieve this.
P,ease find the aspx and aspx.cs code i have written.
the aspx for this
<telerik:RadGrid ID="LoadingRadGrid" OnItemDataBound="LoadingRadGridFormat_OnItemDataBound"
                            runat="server" AutoGenerateColumns="false" CssClass="TransferGridPanel" Height="233px"
                            Width="475px" >
                            <MasterTableView ShowHeadersWhenNoRecords="true">
                           
                                <NestedViewTemplate>
                                
                                    <telerik:RadTabStrip runat="server" ID="LoadTabStip" MultiPageID="LoadMultipage"
                                        SelectedIndex="0" OnTabClick="LoadTabStip_TabClick" Orientation="HorizontalTop">
                                        <Tabs runat="server">
                                            <telerik:RadTab runat="server" Text="Details" PageViewID="RadPageViewDetails">
                                            </telerik:RadTab>
                                            <telerik:RadTab runat="server" Text="Compartments" PageViewID="RadPageViewCompartments">
                                            </telerik:RadTab>
                                            <telerik:RadTab runat="server" Text="Products" PageViewID="RadPageViewProducts">
                                            </telerik:RadTab>
                                        </Tabs>
                                    </telerik:RadTabStrip>
                                    <telerik:RadMultiPage runat="server" ID="LoadMultipage" SelectedIndex="0" RenderSelectedPageOnly="false">
                                   
                                        <telerik:RadPageView runat="server" ID="RadPageViewDetails">
                                       
                                        </telerik:RadPageView>
                                        <telerik:RadPageView runat="server" ID="RadPageViewCompartments">
                                       
                                            <telerik:RadGrid ID="LoadTabRadGrid" runat="server" AutoGenerateColumns="false" CssClass="TransferGridPanel"
                                                Height="233px" Width="475px" >
                                                <MasterTableView ShowHeadersWhenNoRecords="true">                                               
                                                    <Columns>
                                                        <telerik:GridBoundColumn UniqueName="CompNo" DataField="CompartmentIndex">
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn UniqueName="PlannedLoadProd" DataField="PlannedProductName">
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn UniqueName="ActualLoadProd" DataField="ActualProductName">
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn UniqueName="PlannedLoadQty" DataField="PlannedQuantity">
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn UniqueName="ActualLoadQty" DataField="ActualQuantity">
                                                        </telerik:GridBoundColumn>
                                                    </Columns>
                                                </MasterTableView>
                                            </telerik:RadGrid>
                                           
                                        </telerik:RadPageView>
                                    </telerik:RadMultiPage>
                                 
                                </NestedViewTemplate>
                               
                                <Columns>
                                    <telerik:GridBoundColumn UniqueName="LoadId" DataField="Loading_ID">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn UniqueName="TerminalId" DataField="Plant_ID">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn UniqueName="TerminalName" DataField="TerminalName">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn UniqueName="LoadingStartTime" DataField="LoadingStartTime">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn UniqueName="LoadingEndTime" DataField="LoadingEndTime">
                                    </telerik:GridBoundColumn>
                                </Columns>
                             <telerik:RadPageView runat="server" ID="RadPageViewProducts">
                                       
                              </telerik:RadPageView>
                            </MasterTableView>
                            <ClientSettings>
                                <Scrolling AllowScroll="true" />
                            </ClientSettings>
                        </telerik:RadGrid>
aspx.cs file
  protected void LoadTabStip_TabClick(object sender, RadTabStripEventArgs e)
    {
               
        string selectedtabindex = e.Tab.Text;
        Int64 shipmentID = Convert.ToInt64(ShiftTreeView.SelectedNode.Value);
        RadGrid grdLoad=new RadGrid();
       
        switch (selectedtabindex)
        {
            case "Details":
                {
                   
                    break;
                }
            case "Compartments":
                {
                    List<LoadingDetailEntity> loadingTabListinstance = new List<LoadingDetailEntity>();
                    loadingTabListinstance = loadingDetailManager.GetLoadingDetailListByShipmentId(shipmentID);
                    grdLoad.DataSource = loadingTabListinstance;
                    grdLoad.DataBind();
                  
                    e.Tab.Controls.Add(grdLoad);
                    break;
                }
            case "Products":
                {
                    break;
                }
        }
    }

this is what i have written in aspx and aspx.cs files.But i didn't achieved the desired result.

The problem i am facing is that i am not able to get the LoadtabRadgrid control in aspx.cs when i try to bind the data in the  LoadTabStip_TabClick method.
please suggest me the correct way to achieve this reult.

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 1
answered on 28 Aug 2014, 05:10 AM
Hi Sudhakar,

Please take a look at the sample code snippet to add RadGrid inside TabStrip:

ASPX:
<telerik:RadGrid ID="LoadingRadGrid" runat="server" AutoGenerateColumns="false" Height="233px" Width="600px" DataSourceID="dsGrid">
    <MasterTableView ShowHeadersWhenNoRecords="true">
        <NestedViewTemplate>
            <telerik:RadTabStrip runat="server" ID="LoadTabStip" MultiPageID="LoadMultipage" SelectedIndex="0" OnTabClick="LoadTabStip_TabClick" Orientation="HorizontalTop">
                <Tabs runat="server">
                    <telerik:RadTab runat="server" Text="Details" PageViewID="RadPageViewDetails">
                    </telerik:RadTab>
                    <telerik:RadTab runat="server" Text="Compartments" PageViewID="RadPageViewCompartments">
                    </telerik:RadTab>
                    <telerik:RadTab runat="server" Text="Products" PageViewID="RadPageViewProducts">
                    </telerik:RadTab>
                </Tabs>
            </telerik:RadTabStrip>
            <telerik:RadMultiPage runat="server" ID="LoadMultipage" SelectedIndex="0" RenderSelectedPageOnly="false">
                <telerik:RadPageView runat="server" ID="RadPageViewDetails">
                </telerik:RadPageView>
                <telerik:RadPageView runat="server" ID="RadPageViewCompartments">
                </telerik:RadPageView>
                <telerik:RadPageView runat="server" ID="RadPageViewProducts">
                    <telerik:RadGrid ID="grdProducts" runat="server" AutoGenerateColumns="false">
                        <MasterTableView ShowHeadersWhenNoRecords="true">
                            <Columns>
                                <telerik:GridBoundColumn UniqueName="UnitPrice" DataField="UnitPrice">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn UniqueName="Quantity" DataField="Quantity">
                                </telerik:GridBoundColumn>
                            </Columns>
                        </MasterTableView>
                    </telerik:RadGrid>
                </telerik:RadPageView>
            </telerik:RadMultiPage>
        </NestedViewTemplate>
        <Columns>
            <telerik:GridBoundColumn UniqueName="OrderID" DataField="OrderID">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn UniqueName="EmployeeID" DataField="EmployeeID">
            </telerik:GridBoundColumn>
        </Columns>
    </MasterTableView>
    <ClientSettings>
        <Scrolling AllowScroll="true" />
    </ClientSettings>
</telerik:RadGrid>

C#:
protected void LoadTabStip_TabClick(object sender, RadTabStripEventArgs e)
{        
    string selectedtabindex = e.Tab.Text;
    RadGrid grdSample = new RadGrid();
    grdSample.ID = "grdSample" + selectedtabindex;
    grdSample.Width = Unit.Pixel(300);
    switch (selectedtabindex)
    {
        case "Details":
            {
                e.Tab.PageView.Controls.Add(grdSample);
                grdSample.DataSource= Your DataSource;
                grdSample.Rebind();                 
                break;
            }
        case "Compartments":
            {
                e.Tab.PageView.Controls.Add(grdSample);
                grdSample.DataSource= Your DataSource;
                grdSample.Rebind();                  
                break;
            }
        case "Products":
            {
       //To populate a grid which is already declared in the PageView
                RadPageView page = (RadPageView)e.Tab.PageView;              
                RadGrid grdProduct = (RadGrid)page.FindControl("grdProducts");
                grdProduct.DataSource = Your DataSource;
                grdProduct.Rebind();                   
                break;
            }
    }
}

Thanks,
Princy
0
Sudhakar
Top achievements
Rank 1
answered on 28 Aug 2014, 07:16 AM
Thanks for the solution.Its working fine for me.
Tags
Grid
Asked by
Sudhakar
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Sudhakar
Top achievements
Rank 1
Share this question
or