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

How to show the detail grid in expanded mode always

5 Answers 37 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Bala
Top achievements
Rank 1
Bala asked on 14 Dec 2009, 09:10 PM
Hello

Can some one tell me how to show the detail grid in expanded mode always and what are the settings in aspx and code behind, i tried setting "HierarchyDefaultExpanded = true" 
but it didnt helped me

Thank in advance
Bala

 

5 Answers, 1 is accepted

Sort by
0
Schlurk
Top achievements
Rank 2
answered on 14 Dec 2009, 09:39 PM
I think if you use this snippet of code it should work for you:

public partial class _Default : System.Web.UI.Page  
{  
    protected void Page_Load(object sender, EventArgs e)  
    {  
        RadGrid1.MasterTableView.HierarchyDefaultExpanded = true;  
        foreach (GridTableView gtv in RadGrid1.MasterTableView.DetailTables)  
            gtv.HierarchyDefaultExpanded = true;  
    }  
}  

0
Bala
Top achievements
Rank 1
answered on 14 Dec 2009, 09:53 PM
Hi,

Thanks for the snippet but when I use this code, code in the data_bound is getting faild




protected

 

void radgrdCompliance_DataBound(object sender, EventArgs e)

 

{

 

 

foreach (GridDataItem item in radgrdCompliance.Items)

 

{

 

HyperLink prodnameLnk = (HyperLink)item["ProductName"].FindControl("ProdNameLnk"); ==> this is working earliber but when i use the code snippet , HiearchyExpanded = true, its failing, seems its trying to loop thru the child items as well how to fix this issue ?

 

 



HiddenField
hd = (HiddenField)item["ProductName"].FindControl("hdnpid");

 

prodnameLnk.NavigateUrl =

Constants.ProductDetailsPage + "?" + Constants.qspProductId + "=" + hd.Value;

 

}

 

}

alslo do i need set any property in the aspx file ? currently 

 

HierarchyLoadMode

 

="ServerBind"

 

0
Bala
Top achievements
Rank 1
answered on 14 Dec 2009, 10:00 PM
update
added the code in pre_render but no luck. it not showing in expanded mode only the > is changed "expanded mode

protected

 

void radgrdCompliance_PreRender(object sender, EventArgs e)

 

{

 

if (!Page.IsPostBack)

 

{

radgrdCompliance.MasterTableView.HierarchyDefaultExpanded =

true;

 

 

foreach (GridTableView gtv in radgrdCompliance.MasterTableView.DetailTables)

 

{ gtv.HierarchyDefaultExpanded =

true; }

 

}

}

0
Sebastian
Telerik team
answered on 15 Dec 2009, 11:30 AM
Hello Bala,

If you want the code inside the OnDataBound handle to be executed for items in the master table only, your foreach loop should be modified as follows:

foreach (GridDataItem item in radgrdCompliance.MasterTableView.Items)

Additionally, the more convenient approach to set HierarchyDefaultExpanded = true for each level of the hierarchy would be directly in the grid markup as part of the MasterTableView/GridTableView tags. You may also be interested in this documentation topic which explains how to traverse grid items/tables in hierarchical grid.

Best regards,
Sebastian
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
Princy
Top achievements
Rank 1
answered on 15 Dec 2009, 01:01 PM
Hello Bala,

Also the code that you have implemented in the PreRender event, should work if your rebind your grid as shown below:
c#:
protected void radgrdCompliance_PreRender(object sender, EventArgs e) 
  if (!Page.IsPostBack) 
  { 
     radgrdCompliance.MasterTableView.HierarchyDefaultExpanded = true
     foreach (GridTableView gtv in radgrdCompliance.MasterTableView.DetailTables)  
      { gtv.HierarchyDefaultExpanded = true; } 
 
    radgrdCompliance.Rebind(); 
  } 

Hope this helps..
Princy.
Tags
Grid
Asked by
Bala
Top achievements
Rank 1
Answers by
Schlurk
Top achievements
Rank 2
Bala
Top achievements
Rank 1
Sebastian
Telerik team
Princy
Top achievements
Rank 1
Share this question
or