for the example listed here http://demos.telerik.com/aspnet-ajax/grid/examples/hierarchy/autogeneratedhierarchy/defaultcs.aspx
I want to hide a column in child table from code behind .. for example if I wanted to hide the order_ID in the child view how would I do that from code behind when the grid has been created programtically.
I want to hide a column in child table from code behind .. for example if I wanted to hide the order_ID in the child view how would I do that from code behind when the grid has been created programtically.
5 Answers, 1 is accepted
0

Jayesh Goyani
Top achievements
Rank 2
answered on 08 May 2012, 07:02 AM
Hello,
Thanks,
Jayesh Goyani
protected
void
RadGrid1_DetailTableDataBind(
object
sender, GridDetailTableDataBindEventArgs e)
{
e.DetailTableView.Columns.FindByUniqueName(
"YourColumnUniqueName"
).Visible =
false
;
}
Thanks,
Jayesh Goyani
0

John
Top achievements
Rank 1
answered on 09 Oct 2012, 09:31 AM
I am creating the grid from code behind programatically and when I try to put the code as listed, it gives me a column not found error. When I check the number of columns using e.DetailTableView.Columns.count then I get a value of 0 and also e.DetailTableView.RenderColumns.Count
has a value of 2 when there are clearly more columns in the details view
Any thoughts on what I might be missing?
has a value of 2 when there are clearly more columns in the details view
Any thoughts on what I might be missing?
0
Hello John,
Please try the following approach:
I hope this will prove helpful. Please give it a try and let me know about the result.
All the best,
Eyup
the Telerik team
Please try the following approach:
protected
void
RadGrid1_PreRender(
object
sender, EventArgs e)
{
HideColumnRecursive(RadGrid1.MasterTableView);
}
public
void
HideColumnRecursive(GridTableView tableView)
{
GridItem[] nestedViewItems = tableView.GetItems(GridItemType.NestedView);
foreach
(GridNestedViewItem nestedViewItem
in
nestedViewItems)
{
foreach
(GridTableView nestedView
in
nestedViewItem.NestedTableViews)
{
GridColumn column = nestedView.GetColumnSafe(
"OrderID"
)
as
GridColumn;
if
(column !=
null
)
{
column.Visible =
false
;
}
if
(nestedView.HasDetailTables)
{
HideColumnRecursive(nestedView);
}
}
}
}
I hope this will prove helpful. Please give it a try and let me know about the result.
All the best,
Eyup
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0

Madhav Joshi
Top achievements
Rank 2
answered on 19 Dec 2012, 09:45 AM
Hi Eyup,
I tried you approach and i couldnot get any Result as Expected :( . Please give an alternative for the same. Along with that i want to remove the Nested Gridviews's headers also.
Thanks,
Madhav Joshi
I tried you approach and i couldnot get any Result as Expected :( . Please give an alternative for the same. Along with that i want to remove the Nested Gridviews's headers also.
Thanks,
Madhav Joshi
0
Hi Madhav,
I have created a sample RadGrid web site to demonstrate that the suggested approach works as expected. Please check out the attached application and let me know about the result.
All the best,
Eyup
the Telerik team
I have created a sample RadGrid web site to demonstrate that the suggested approach works as expected. Please check out the attached application and let me know about the result.
All the best,
Eyup
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.