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

NestedView Data binding

10 Answers 108 Views
Grid
This is a migrated thread and some comments may be shown as answers.
John John
Top achievements
Rank 1
John John asked on 02 Nov 2009, 11:09 AM
Hi
       I have one doubt in how to bind Netedview template grid data programatically.
Suppose i have the cutomer grid,it has nested view grid called Order grid in one of my tab section. My question is how to bind the order data based on the customer id selected. i could do the same on ordinary hierarchial grid with the help of  "RadGrid1_DetailTableDataBind",
 
is there any alternate event for binding the order table?


--Thanks
 

10 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 02 Nov 2009, 01:20 PM
Hello John,

Basic steps that you need to follow in order to create hierarchical Telerik RadGrid programmatically, are shown in the help article bellow:
Programmatic creation

Best wishes,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
John John
Top achievements
Rank 1
answered on 02 Nov 2009, 01:41 PM
Hi Pavlina,
                  thanks for your response, i know the basic way of binding the Heierarchial grid. But my question is how can i bind the grid which is inside the NestedView template section.How can i make control over the Nested Grid and its detail table, which event would help to do the same scenario

Hope u could undestand my scenario..

-Thanks
0
Princy
Top achievements
Rank 1
answered on 03 Nov 2009, 06:38 AM
Hi John,

You can make use of the NeedDataSource event of the nested grid to populate it based on its parent key value. Here is an example:
c#:
protected void RadGrid2_NeedDataSource(object source, GridNeedDataSourceEventArgs e) 
    { 
        RadGrid nestedgrid = (RadGrid)source; 
        GridNestedViewItem dataItem = (GridNestedViewItem)nestedgrid.NamingContainer; 
        GridDataItem parentItem = (GridDataItem)dataItem.ParentItem; 
        string strtxt = parentItem.GetDataKeyValue("CustomerID").ToString(); 
 
        // populate the nested grid based on the customer id of the parent item.. 
 
    } 

Thanks
Princy.
0
John John
Top achievements
Rank 1
answered on 03 Nov 2009, 08:20 AM
Hi Princy
         The event "RadGrid2_NeedDataSource" is not firing in order to bind the nested grid. This method is not getting fired during load time as like the RadGrid1_NeedDataSource fires. Should i need to set any additional thngs to work it fine.

I declared the event in my nested grid at design time too, but no use.

-Thanks
0
John John
Top achievements
Rank 1
answered on 03 Nov 2009, 11:47 AM
Hi
     any one please guide me to make it work for my above question


-Thanks
0
Pavlina
Telerik team
answered on 04 Nov 2009, 04:19 PM
Hello John,

Please check out the following forum thread which discuss a similar problem and see if it helps.
http://www.telerik.com/community/forums/aspnet-ajax/grid/how-to-bind-inner-grid-of-hierarchy-with-templates-grid.aspx

Best wishes,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
John John
Top achievements
Rank 1
answered on 22 Jan 2010, 02:01 PM
Hello Telerik Team,
         As per the direction i used the below code to bind the NestedView grid. It is working fine as i expected. 

    protected void RadGrid1_PreRender(object sender, EventArgs e)  
    {  
  
        foreach (GridDataItem item in RadGrid1.MasterTableView.Items)  
        {  
            if (item.Expanded)  
            {  
  
                foreach (GridNestedViewItem item1 in RadGrid1.MasterTableView.GetItems(GridItemType.NestedView))  
                {  
                    RadGrid grid = (RadGrid)item1.FindControl("RadGrid2");  
                    grid.DataSource = "  "//set the DataSource here 
                }  
            }  
        }  
   }  

But i am facing now a problem in setting the  MasterTableView-HierarchyLoadMode="Client" option instead of  "server" option.
The grid has not been binded well when the hierarchy loadmode is set to client. Is there any other way to achieve the scenario or is it is default behavior of grid control.

--Thanks
0
Pavlina
Telerik team
answered on 22 Jan 2010, 05:20 PM
Hi John,

When HierarchyLoadMode is set to Client items are expanded client-side, using JavaScript manipulations, instead of postback to the server.  
In order to use client-side hierarchy expand, you will need to set also ClientSettings.AllowExpand.Collapse  to true.

For more information, please refer to the following article:
Hierarchy load modes

Sincerely yours,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
John John
Top achievements
Rank 1
answered on 25 Jan 2010, 06:48 AM
Hello Telerik,
                    I used the code menioned below to the Grid as per your direction. But still it is not loading with data. Only a tab sections inside the panel are visible rather than displaying data in each tab section.

MasterTableView-HierarchyLoadMode

="Client"
ClientSettings-AllowExpandCollapse="true"

 


Suppose is there any other option should i need to do in order to make it is functioning well.

-Thanks
0
Pavlina
Telerik team
answered on 25 Jan 2010, 10:55 AM
Hello John,

If your problem persists, it will be best if you can send us a simple running project (incl. CSS, images, skins, DB backup if needed and so on) demonstrating the problem. Thus we will review it locally and advice you further.

Kind regards,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
John John
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
John John
Top achievements
Rank 1
Princy
Top achievements
Rank 1
Share this question
or