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

Custom edit in nested grid

13 Answers 193 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alice
Top achievements
Rank 1
Alice asked on 12 Aug 2008, 12:56 AM
Okay so I've been through the forums and the tutorials but I must have a hard head this week because I'm still not getting it.  :)

How do I create a custom edit form for a nested grid?   I want to change a couple of the text boxes to combo boxes, but when I tried it in the source code it didn't work, i.e. it didn't look like I did anything.

13 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 12 Aug 2008, 04:24 AM
Hello Alice,

I would suggest you to use GridDropDownColumns instead of GridBoundColumns where data appears as in GridBoundColumns, when in Normal mode and when in Edit mode data would be bound to dropdownlists.
aspx:
 <telerik:GridDropDownColumn UniqueName="DropDownListColumn" ListTextField="CustomerID" ListValueField="CustomerID" DataSourceID="SqlDataSource1" DataField="ContactName" > 
 </telerik:GridDropDownColumn> 

You can also refer to this link - Column Types

Another alternative would be to replace the default Edit form with a UserControlEditForm or TemplateEditForm .

Thanks
Princy.
0
Alice
Top achievements
Rank 1
answered on 14 Aug 2008, 12:13 AM
Thanks,

That's all good but I'm still not sure where in the code I'm supposed to effect the changes, or what property to use.  Is it done under the master table or the nested grid? 
0
Shinu
Top achievements
Rank 2
answered on 14 Aug 2008, 05:33 AM
Hi Alice,
 
This is how you can implement a template Editform for the master and child table in Grid hierarchy.

ASPX:
 <telerik:RadGrid ID="RadGrid1" runat="server"    AllowMultiRowSelection="True" DataSourceID="SqlDataSource1"  > 
            <MasterTableView DataSourceID="SqlDataSource1"   EditMode="EditForms"    > 
                <EditFormSettings EditFormType="Template" > 
                    <FormTemplate> 
                        <telerik:RadComboBox ID="RadComboBox1" runat="server" > 
                        </telerik:RadComboBox> 
                    </FormTemplate> 
                 </EditFormSettings> 
                
                <Columns> 
                    <telerik:GridBoundColumn DataField="FirstName" HeaderText="FirstName" SortExpression="FirstName" 
                        UniqueName="FirstName"
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn DataField="LastName" HeaderText="LastName" SortExpression="LastName" 
                        UniqueName="LastName"
                    </telerik:GridBoundColumn> 
                    <telerik:GridEditCommandColumn> 
                    </telerik:GridEditCommandColumn> 
                </Columns> 
               
             <DetailTables> 
                <telerik:GridTableView runat="server"  EditMode="EditForms"  DataSourceID="SqlDataSource1" > 
                 <EditFormSettings EditFormType="Template" > 
                    <FormTemplate> 
                        <telerik:RadComboBox ID="RadComboBox2" runat="server" > 
                        </telerik:RadComboBox> 
                    </FormTemplate> 
                 </EditFormSettings> 
                 <Columns> 
                  <telerik:GridBoundColumn DataField="FirstName" HeaderText="FirstName" SortExpression="FirstName" 
                        UniqueName="FirstName"
                    </telerik:GridBoundColumn> 
                    <telerik:GridEditCommandColumn></telerik:GridEditCommandColumn> 
                 </Columns> 
                </telerik:GridTableView> 
              </DetailTables> 
            </MasterTableView> 
        </telerik:RadGrid> 


Thanks
Shinu.
0
Alice
Top achievements
Rank 1
answered on 16 Aug 2008, 04:37 PM
Thanks,

That's what I needed.  I'm about half way there now.  I've got the form set up the way I want it, but the "cancel" and the "update" links don't show up.

I just need to know how to add them back in.  :)


0
Yavor
Telerik team
answered on 18 Aug 2008, 05:22 AM
Hi Alice,

Since you are using a Template edit form for the inner grid, you will need to manually include Cancel/Update Buttons or link buttons for the form. These must also have the appropriate commandName. I hope this information helps.

Kind regards,
Yavor
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Shinu
Top achievements
Rank 2
answered on 18 Aug 2008, 07:03 AM
Hi Alice,

Try placing the Update and Cancel Linkbuttons in the FormTemplate as shown below.

ASPX:
<EditFormSettings  EditFormType="Template"  > 
                    <FormTemplate> 
                        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> 
                        <asp:LinkButton ID="LinkButton3" runat="server" Text="Update" CommandName="Update"  ></asp:LinkButton> 
                        <asp:LinkButton ID="LinkButton2" runat="server" Text="Cancel" CommandName="Cancel" ></asp:LinkButton> 
                    </FormTemplate> 
                 </EditFormSettings> 


CS:
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)  
    {  
        if (e.CommandName == "Update")  
        {   
          
        }  
    } 


Thanks
Shinu.
0
Alice
Top achievements
Rank 1
answered on 24 Aug 2008, 06:41 PM
Thanks,

I've added the link buttons in the form but I'm not sure about the code for the click event, since it's in a nested grid.  Could you help me with the code for this in vb?
0
Accepted
Shinu
Top achievements
Rank 2
answered on 25 Aug 2008, 05:07 AM
Hi Alice,

ItemCommand event will fire for both master and detail table. Make sure that you have set the CommandName property for the LinkButton in the aspx. Here is the code snippet in VB.

VB:
 Protected Sub RadGrid1_ItemCommand(ByVal source As Object, ByVal e As GridCommandEventArgs) 
            
     If e.CommandName = "Update" Then 
     End If 
 End Sub 


Thanks
Shinu.
0
Alice
Top achievements
Rank 1
answered on 27 Aug 2008, 11:46 PM
Thanks, I think I have it.  :)  I really appreciated the help.
0
Shinu
Top achievements
Rank 2
answered on 28 Aug 2008, 03:45 AM
Hi Alice,

You can use the following link to convert code from C# to VB and viceversa.
http://converter.telerik.com/

Regards
Shinu
0
Bill
Top achievements
Rank 1
answered on 30 Aug 2008, 08:38 PM
Hello Alice,

There is a really good video on how to create a custom edit form

Video 45
0
Alice
Top achievements
Rank 1
answered on 06 Sep 2008, 03:08 PM
That was a great vid thanks.

Well guys,

Everything is working perfect except insert.  Here is what I have in the code:

Private Sub RadGridGoals_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGridGoals.ItemCommand

Select e.CommandName

Case e.CommandName = "Update"

Me.ObjectDataSourceGoals.Update()

Case e.CommandName = "Cancel"

Me.RadGridGoals.Rebind()

End Select

End Sub

Here's what I tried:

Private Sub RadGridGoals_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGridGoals.ItemCommand

Select e.CommandName

Case e.CommandName = "Update"

Me.ObjectDataSourceGoals.Update()

Case e.CommandName = "Cancel"

Me.RadGridGoals.Rebind()

Case e.CommandName = "Insert"

Me.ObjectDataSourceGoals.Insert()

End Select

End Sub

Any suggestions?

0
Yavor
Telerik team
answered on 08 Sep 2008, 05:36 AM
Hello Alice,

Based on the code supplied, it is hard to determine the cause of the issue. To further investigate it, you can open a formal support ticket, and send us a small project sample, for additional testing.

Sincerely yours,
Yavor
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Alice
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Alice
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Yavor
Telerik team
Bill
Top achievements
Rank 1
Share this question
or