hi i would like to use a linkbutton from a mastertableview to open detailtables edit form. is this possible? thank you.
<telerik:GridTemplateColumn UniqueName="InsertCommandColumn" HeaderText="">
<ItemTemplate>
<asp:LinkButton ID="btn_Insert" runat="server" Text="Add Detail" CommandName="InitInsert" />
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn UniqueName="InsertCommandColumn" HeaderText="">
<ItemTemplate>
<asp:LinkButton ID="btn_Insert" runat="server" Text="Add Detail" CommandName="InitInsert" />
</ItemTemplate>
</telerik:GridTemplateColumn>
4 Answers, 1 is accepted
0
Duy
Top achievements
Rank 1
answered on 18 Jun 2013, 10:27 PM
i was able to do this with
however, if the parent has no child it will crash. So i put the if nestedView.items.count>0 in but how do i overcome this issue so i can still perform insert without having any child. thank you for your help.
f e.CommandName = "AddDetail" Then Dim parentRow As GridDataItem = TryCast(e.Item, GridDataItem) TryCast(e.Item, GridDataItem).Expanded = True Dim nestedView As GridTableView = parentRow.ChildItem.NestedTableViews(0) If nestedView.Items.Count > 0 Then nestedView.Items(0).FireCommandEvent("InitInsert", [String].Empty) End If End If0
Duy
Top achievements
Rank 1
answered on 19 Jun 2013, 02:13 PM
anyone has any idea how to fix this? thanks
0
Hi,
You could achieve your goal by using the following method:
You should replace the "
Regards,
Andrey
Telerik
You could achieve your goal by using the following method:
public void ExpandGridRecursively(GridTableView tableView){ GridItem[] nestedViewItems = tableView.GetItems(GridItemType.NestedView); foreach (GridNestedViewItem nestedViewItem in nestedViewItems) { foreach (GridTableView nestedView in nestedViewItem.NestedTableViews) { if (nestedView.Name == "SearchedTableView") { nestedViewItem.Expanded=true; } if (nestedView.HasDetailTables) { HideExpandColumnRecursive(nestedView); } } }}You should replace the "
SearchedTableView" with the name of the TableVIew object you want to expand. You could call this method inside the Button click handler and pass the MasterTableVIew object of RadGrid.Regards,
Andrey
Telerik
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 the blog feed now.
0
Foram
Top achievements
Rank 1
answered on 02 Aug 2013, 05:57 AM
Hi Duy,
To insert the record if detail grid not contain any records use the following code -
if (e.CommandName == "Add")
{
GridDataItem parentItem = (GridDataItem)e.Item.OwnerTableView.ParentItem;
GridTableView nestedView = parentItem.ChildItem.NestedTableViews[0];
if (nestedView != null && nestedView.Items.Count > 0)
{
nestedView.Items[0].FireCommandEvent("InitInsert", String.Empty);
}
else
{
nestedView.IsItemInserted = true;
nestedView.Rebind();
}
}
To insert the record if detail grid not contain any records use the following code -
if (e.CommandName == "Add")
{
GridDataItem parentItem = (GridDataItem)e.Item.OwnerTableView.ParentItem;
GridTableView nestedView = parentItem.ChildItem.NestedTableViews[0];
if (nestedView != null && nestedView.Items.Count > 0)
{
nestedView.Items[0].FireCommandEvent("InitInsert", String.Empty);
}
else
{
nestedView.IsItemInserted = true;
nestedView.Rebind();
}
}