Hey Telerik pros,
Could use your help on this one...
I'm trying to use a nested RadGrid to show a BOM (bill of materials) i.e. parts are composed of simpler parts, which may in turn be composed of even simpler parts, etc.
I have a grid like so, using HierarchyLodeMode="ServerBind", and Unique_Id and Parent_Id to create a self-referencing hierarchy.
And in the PreRender, hiding the expand column for those rows that don't have anything nested beneath them:
And all that works great, I can get the self-referencing hierarchical grid of X levels (where X isn't known until you get the data).
Now, my problem is trying to convert the type of these auto-generated columns, from the regular GridBoundColumn to something like GridHyperLinkColumn. I can't figure out how to do that, maybe it's not possible?
As another approach, I tried adding a GridHyperLinkColumn to the nested views during the PreRender event, but I can't get that to work either.
Does anybody have any suggestions on how to either a) convert the type of these auto-generated columns or b) dynamically add another column to the grid? All I really want is to be able to add a hyperlink to each row in this type of nested grid.
Much thanks,
ET
Could use your help on this one...
I'm trying to use a nested RadGrid to show a BOM (bill of materials) i.e. parts are composed of simpler parts, which may in turn be composed of even simpler parts, etc.
I have a grid like so, using HierarchyLodeMode="ServerBind", and Unique_Id and Parent_Id to create a self-referencing hierarchy.
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
OnNeedDataSource
=
"RadGrid1_NeedDataSource"
OnPreRender
=
"RadGrid1_PreRender"
AllowSorting
=
"True"
>
<
MasterTableView
HierarchyLoadMode
=
"ServerBind"
AllowSorting
=
"true"
DataKeyNames
=
"Unique_Id, Parent_Id"
>
<
SelfHierarchySettings
ParentKeyName
=
"Parent_Id"
KeyName
=
"Unique_Id"
/>
</
MasterTableView
>
<
ClientSettings
AllowExpandCollapse
=
"true"
>
<
Selecting
AllowRowSelect
=
"True"
></
Selecting
>
</
ClientSettings
>
</
telerik:RadGrid
>
Then, in the code-behind, using OnNeedDataSource event:protected
void
RadGrid1_NeedDataSource(
object
source, GridNeedDataSourceEventArgs e)
{
RadGrid1.DataSource = GetDataTable();
//fetches data, returns DataTable
}
And in the PreRender, hiding the expand column for those rows that don't have anything nested beneath them:
protected
void
RadGrid1_PreRender(
object
sender, EventArgs e)
{
HideOrShowExpandColumnRecursive(RadGrid1.MasterTableView);
}
protected
void
HideOrShowExpandColumnRecursive(GridTableView tableView)
{
GridItem[] nestedViewItems = tableView.GetItems(GridItemType.NestedView);
foreach
(GridNestedViewItem nestedViewItem
in
nestedViewItems)
{
foreach
(GridTableView nestedView
in
nestedViewItem.NestedTableViews)
{
if
(nestedView.Items.Count == 0)
{
TableCell cell = nestedView.ParentItem[
"ExpandColumn"
];
cell.Controls[0].Visible =
false
;
nestedViewItem.Visible =
false
;
}
if
(nestedView.HasDetailTables)
{
HideOrShowExpandColumnRecursive(nestedView);
}
}
}
}
And all that works great, I can get the self-referencing hierarchical grid of X levels (where X isn't known until you get the data).
Now, my problem is trying to convert the type of these auto-generated columns, from the regular GridBoundColumn to something like GridHyperLinkColumn. I can't figure out how to do that, maybe it's not possible?
As another approach, I tried adding a GridHyperLinkColumn to the nested views during the PreRender event, but I can't get that to work either.
Does anybody have any suggestions on how to either a) convert the type of these auto-generated columns or b) dynamically add another column to the grid? All I really want is to be able to add a hyperlink to each row in this type of nested grid.
Much thanks,
ET