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

Open child grid insert form from datarow

3 Answers 102 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 1
Jon asked on 15 Dec 2010, 05:06 PM
Hi,

I've managed to make a grid work with a subgrid and popup admin forms for the two levels.  Now that I have it largely working I am looking at making it more usable for the end user.  As it stands with command bars it looks very complex so I've kept the command bar on the top of the grid, that is fine for adding new elements to level 1.  On the second level I decided that the command bar was wasting too much space so I have put a + button in each row in level 1 - this can be seen in the attached screenshot.

The problem that I have is by moving the + button to the row the code that handles default checkbox config on the form template now fails. My insert form code is shown below - the top part handles creation of the form for the level 1 grid while the second one (with a renamed CommandName) needs to open the child grids insert form.  

I think that I'm just tired but cannot figure out howto get the child form open.  

Any pointers?

Regards,

Jon

Private Sub uxRadGrid_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles uxRadGrid.ItemCommand
        If e.CommandName = Telerik.Web.UI.RadGrid.InitInsertCommandName Then
            e.Canceled = True
            Dim newValues As System.Collections.Specialized.ListDictionary = New System.Collections.Specialized.ListDictionary()
            newValues("ShowTotal") = False
            newValues("IncludeInGrandTotal") = False
            e.Item.OwnerTableView.InsertItem(newValues)
        ElseIf e.CommandName = "InitInsertElement" Then
            e.Canceled = True
            Dim newValues As System.Collections.Specialized.ListDictionary = New System.Collections.Specialized.ListDictionary()
            newValues("IncludeInTotal") = False
' FOLLOWING LINE CRASHES BECAUSE IT IS INSERTING IN THE LEVEL 1 GRID - NOT THE CHILD GRID.  
' NEED CODE FOR OPENING CHILD INSERT FORM
            e.Item.OwnerTableView.InsertItem(newValues)
        ElseIf (e.CommandName = "Update" OrElse
.... rest irrelevant

3 Answers, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 16 Dec 2010, 11:25 AM
Hello Jon,

I am not sure how you are adding the button to the detail rows, but the best way is to use a GridButtonColumn with a CommandName="InitInsert".

Hope it helps.

Greetings,
Tsvetoslav
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Jon
Top achievements
Rank 1
answered on 16 Dec 2010, 11:34 AM
Hi Tsvetoslav,

I am adding the button to the row as a GridTemplateColumn with an image setup inside that.  I've tried with a GridButtonColumn as you suggest but that has the same effect.

Please note that essentially the problem is that InitInsert will work on the same level as the row - thus in this case it will try to insert a new row at the level 1.  I need this button press to affect the second level sub grid NOT the same level....

You can see in my code sample that the top section deals with a new admin form being created at level 1.  I need help with thesecond part - specifically the last line that should open the child grid's admin form...

Regards,

Jon
0
Jon
Top achievements
Rank 1
answered on 16 Dec 2010, 01:48 PM
Figured it out.  In case anyone needs to do the same thing in the future the code is 

DirectCast(e.Item, Telerik.Web.UI.GridDataItem).ChildItem.NestedTableViews(0).InsertItem(newValues)

Cheers,

Jon
Tags
Grid
Asked by
Jon
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Jon
Top achievements
Rank 1
Share this question
or