Hi. Is it possible to expand a hierarchical grid via a hyperlink column? I noticed you can create a GridExpandColumn but I need a DataField or value instead of the expand arrow, hopefully a hyperlink of some sort. Also, if this is possible, how do I hide the default expand column for just that grid and not any other? Thanks.
Daniel
Daniel
7 Answers, 1 is accepted
0
Accepted

Princy
Top achievements
Rank 2
answered on 26 Nov 2009, 05:30 AM
Hi Daniel,
One suggestion would be using LinkButton in GridTemplateColumn and explicitly expand/collapse the item in ButtonClick event as show below.
ASPX:
CS:
Thanks,
Princy.
One suggestion would be using LinkButton in GridTemplateColumn and explicitly expand/collapse the item in ButtonClick event as show below.
ASPX:
<Columns> |
<telerik:GridTemplateColumn UniqueName="ExpandCollapse"> |
<ItemTemplate> |
<asp:LinkButton ID="LinkButton1" Text='<%# Bind("CustomerID") %>' runat="server" |
OnClick="LinkButton1_Click">LinkButton</asp:LinkButton> |
</ItemTemplate> |
</telerik:GridTemplateColumn> |
. . . |
CS:
protected void LinkButton1_Click(object sender, EventArgs e) |
{ |
LinkButton lnkButton = (LinkButton) sender; |
GridDataItem item = (GridDataItem)lnkButton.NamingContainer; |
item.Expanded = !(item.Expanded); |
} |
protected void RadGrid1_ColumnCreated(object sender, GridColumnCreatedEventArgs e) |
{ |
if(e.Column.UniqueName == "ExpandColumn") |
{ |
e.Column.Visible = false; // Hide the Expand/Collapse column |
} |
} |
Thanks,
Princy.
0

Daniel
Top achievements
Rank 1
Iron
Iron
Iron
answered on 26 Nov 2009, 11:33 PM
Thanks Princy that did the trick except it hides the expand arrow and the column seems to have remained and gotten wider?? Weird. Sorry to add to the complexity of it but is there any way to display an asp label instead of a linkbutton based on the cells value. So for example, if the value is 0 show a label, but for any other value show the linkbutton. Thanks for your help, much appreciated.
Daniel
Daniel
0
Accepted

Princy
Top achievements
Rank 2
answered on 30 Nov 2009, 07:25 AM
Hi Daniel,
You can try out the following code to replace the LinkButtons with Labels based on values:
aspx:
Thanks
Princy.
You can try out the following code to replace the LinkButtons with Labels based on values:
aspx:
<telerik:GridTemplateColumn UniqueName="ExpandCollapse"> |
<ItemTemplate> |
<asp:Label ID="Label1" runat="server" Text='<%# Bind("CustomerID") %>' Visible='<%#DataBinder.Eval(Container.DataItem,"CustomerID").ToString()=="0"?true:false%>'></asp:Label> |
<asp:LinkButton ID="LinkButton1" Text='<%# Bind("CustomerID")%>' Visible='<%#DataBinder.Eval (Container.DataItem,"CustomerID").ToString()!="0"?true:false %>' runat="server" OnClick="LinkButton1_Click"></asp:LinkButton> |
</ItemTemplate> |
</telerik:GridTemplateColumn> |
Thanks
Princy.
0

Daniel
Top achievements
Rank 1
Iron
Iron
Iron
answered on 30 Nov 2009, 10:38 PM
Thanks heaps Princy that worked great! Sorry to be a pain, but I have one more minor problem. It's hard to describe so I've attached a screen. It looks like an expand column (but not button) appears next to the last nested table despite the fact that I've tried hidding all expand columns except the first one. Thanks again.
0
Accepted

Princy
Top achievements
Rank 2
answered on 01 Dec 2009, 11:03 AM
Hello Daniel,
Try out the following css code to hide the expandcolumn for all tableviews other than the master and see if it helps solve your isue:
aspx:
css:
Thanks
Princy.
Try out the following css code to hide the expandcolumn for all tableviews other than the master and see if it helps solve your isue:
aspx:
<telerik:RadGrid ID="RadGrid1" DataSourceID="SqlDataSource1" AutoGenerateColumns="false" runat="server"> |
<MasterTableView Name="Master" DataSourceID="SqlDataSource1"> |
<DetailTables> |
<telerik:GridTableView CssClass="MyDetail" Name="Detail" DataSourceID="SqlDataSource2" runat="server"> |
<DetailTables> |
<telerik:GridTableView....... |
css:
.MyDetail .rgExpandCol |
{ |
display:none; |
} |
Thanks
Princy.
0

Daniel
Top achievements
Rank 1
Iron
Iron
Iron
answered on 01 Dec 2009, 11:38 PM
Thanks Princy. I was was trying to apply the style to the wrong GridTableView, but all is good! Thanks again.
Daniel
Daniel
0

Doug
Top achievements
Rank 1
answered on 23 Aug 2011, 03:54 AM
Princy, Thanks for the solution. Would you happen to have a client-side version of this exact feature?
Thanks
Doug
Thanks
Doug