This is a migrated thread and some comments may be shown as answers.

Popup detail insert from master button

4 Answers 85 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Lucania
Top achievements
Rank 1
Lucania asked on 08 May 2012, 03:11 AM
I have a master/detail radgrid. The detail table's EditMode is set to popup, and it has an EditFormTemplate. I would like to be able to initiate the detail table's insert popup from a button in the master. I tried trapping the button command in code behind and doing: e.Item.OwnerTableView.DetailTables[0].InsertItem(); but that doesn't seem to work.

The insert popup works fine from a standard command button on the detail table's command strip, but I would like to do it from the master button so I can remove the detail command strip altogether.

Is there any way to do that?

Thanks

Ross Crawford

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 08 May 2012, 06:58 AM
Hi Ross,

I have put a GridButtonColumn in the Parent Table and set a CommandName to access the row in the ItemCommand event and to show its detail table in insert popup. Please take a look into the following code snippet.

C#:
protected void RadGrid1_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
{
    if (e.CommandName == "CommandName")
    {
        GridDataItem ditem = (GridDataItem)e.Item;
        ditem.Expanded = true;
        GridTableView tableView = (GridTableView)ditem.ChildItem.NestedTableViews[0];
        tableView.IsItemInserted = true;
        tableView.Rebind();
    }
}

Hope this helps.

Thanks,
Shinu.
0
Lucania
Top achievements
Rank 1
answered on 08 May 2012, 08:12 AM
Thanks Shinu,

That got the popup working, however another issue occurs that I can't work out. The query for the detail table has 2 calculated fields, Status and StatusImage. I have a column defined:
<telerik:GridImageColumn UniqueName="Status" HeaderText="" SortExpression="Status" DataAlternateTextField="Status" DataImageUrlFields="StatusImage" />

This all works fine. I have an edit button on each row that displays the same popup for editing, and that works fine too. But when I click the add button with your code (adapted), I get an exception: "Column 'Status' does not belong to table DefaultView.". BUT if I manually expand the master item first, it correctly opens the popup!

Anyone know why that would happen?

Thanks

ROSCO
0
Shinu
Top achievements
Rank 2
answered on 08 May 2012, 09:10 AM
Hi Ross,

Unfortunately I can't replicate the issue.Please provide your code for further help.

Thanks,
Shinu.
0
Lucania
Top achievements
Rank 1
answered on 16 May 2012, 03:35 AM
Thanks for looking at this Shinu. I have changed the way this screen works, and the problem doesn't exist any more, but I will try to create a small example when I get a chance, so you can have a look at it.

ROSCO
Tags
Grid
Asked by
Lucania
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Lucania
Top achievements
Rank 1
Share this question
or