I have a RadGrid with header and details. I have the ParentTableRelation set up. What I want to do is set up a CommandItemTemplate that contains a link that calls a JavaScript function that in turn does a window.radopen. So far the Add New Detail link works fine.
However what I want is something like this: <a href="#" onclick="return AddDetail(DetailId);">Add New Detail</a>
What is the simplest way to add the DetailId to that call?
<MasterTableView EditMode="PopUp" DataKeyNames="HeaderId" ClientDataKeyNames="HeaderId" Name="Header" CommandItemDisplay="Top" AllowPaging="True">
<DetailTables>
<telerik:GridTableView runat="server" DataKeyNames="HeaderId,DetailId" ClientDataKeyNames="HeaderId, DetailId" DataMember="Details" Name="Details" CommandItemDisplay="Top" NoDetailRecordsText="No Detail records to display." HeaderStyle-BackColor="LightCyan"
AlternatingItemStyle-BackColor="LightCyan">
<CommandItemTemplate>
<table style="width: 100%">
<tr>
<td style="width: 160px">
<a href="#" onclick="return AddDetail();">Add New Detail</a>
</td>
</tr>
</table>
</CommandItemTemplate>
Sorry. Too fast again. The solution was to change that to an Asp:Hyperlink and do a call in the ItemCreated event.
if (e.Item is GridCommandItem)
{
GridCommandItem commandItem = e.Item as GridCommandItem;
HyperLink editLink = (HyperLink)commandItem.FindControl("AddDetail");
editLink.Attributes["href"] = "#";
editLink.Attributes["onclick"] = String.Format("return AddDetail('{0}');", e.Item.OwnerTableView.ParentItem.GetDataKeyValue("DetailId"));
}
However what I want is something like this: <a href="#" onclick="return AddDetail(DetailId);">Add New Detail</a>
What is the simplest way to add the DetailId to that call?
<MasterTableView EditMode="PopUp" DataKeyNames="HeaderId" ClientDataKeyNames="HeaderId" Name="Header" CommandItemDisplay="Top" AllowPaging="True">
<DetailTables>
<telerik:GridTableView runat="server" DataKeyNames="HeaderId,DetailId" ClientDataKeyNames="HeaderId, DetailId" DataMember="Details" Name="Details" CommandItemDisplay="Top" NoDetailRecordsText="No Detail records to display." HeaderStyle-BackColor="LightCyan"
AlternatingItemStyle-BackColor="LightCyan">
<CommandItemTemplate>
<table style="width: 100%">
<tr>
<td style="width: 160px">
<a href="#" onclick="return AddDetail();">Add New Detail</a>
</td>
</tr>
</table>
</CommandItemTemplate>
Sorry. Too fast again. The solution was to change that to an Asp:Hyperlink and do a call in the ItemCreated event.
if (e.Item is GridCommandItem)
{
GridCommandItem commandItem = e.Item as GridCommandItem;
HyperLink editLink = (HyperLink)commandItem.FindControl("AddDetail");
editLink.Attributes["href"] = "#";
editLink.Attributes["onclick"] = String.Format("return AddDetail('{0}');", e.Item.OwnerTableView.ParentItem.GetDataKeyValue("DetailId"));
}