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

Edit mode for Child Grids

5 Answers 123 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Murray
Top achievements
Rank 1
Murray asked on 29 Aug 2008, 10:21 PM
I was able to force my main grid into edit mode by using the pre-render event as discussed in the documentation.  I would like to force only my child grid into edit mode, how do I do that?

Murray

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 01 Sep 2008, 05:11 AM
Hi Murray,

Set the Name property for the Detail table and try the following code snippet to set the Detail table in edit mode.

CS:
 protected void RadGrid1_PreRender(object sender, EventArgs e) 
    { 
        foreach (GridDataItem item in RadGrid1.Items) 
        { 
            if (item.OwnerTableView.Name == "Detail") 
            { 
                item.Edit = true
            } 
 
        } 
        RadGrid1.Rebind(); 
    } 


Thanks
Shinu.
0
Murray
Top achievements
Rank 1
answered on 02 Sep 2008, 10:51 PM
Thanks Shinu:

I forgot to mention to you that my project is in VB.  The logic of your code seems to limit the edit mode to just the named child table, is this correct?  My code currently only sets the master table in edit mode.  Will your code work in this circumstance?

Murray
0
Shinu
Top achievements
Rank 2
answered on 03 Sep 2008, 03:44 AM
Hi Murray,

Yes the above given code sets all the items of detail table in edit mode. Here is the equivalent code in VB:

Protected Sub RadGrid1_PreRender(ByVal sender As Object, ByVal e As EventArgs) 
    For Each item As GridDataItem In RadGrid1.Items 
        If item.OwnerTableView.Name = "Detail" Then 
            item.Edit = True 
 
        End If 
    Next 
    RadGrid1.Rebind() 
End Sub 
 

Note: You have to set the Name property for the child table.
<DetailTables> 
      <telerik:GridTableView runat="server" Name="Detail"  > 
                   


Thanks
Shinu.
0
Murray
Top achievements
Rank 1
answered on 03 Sep 2008, 11:27 PM
Hello Shinu:

When I put your code in my project, I cannot expand the grid.  If I encapsulate your code in a If Not IsPostBack structure, then I can expand the grid, but cannot force the detail tables into edit mode.

Any ideas?

Regards

Murray
0
Princy
Top achievements
Rank 2
answered on 04 Sep 2008, 04:49 AM
Hi Murray,

Give a try with the following code snippet and see if it helps.

VB:
Protected Sub RadGrid1_PreRender(ByVal sender As Object, ByVal e As EventArgs) 
 
    For Each item As GridDataItem In RadGrid1.Items 
        Dim indx As Integer = item.ItemIndex 
        If item.Expanded Then 
            Dim gridTableView As GridTableView = (TryCast(RadGrid1.MasterTableView.Items(indx), GridDataItem)).ChildItem.NestedTableViews(0) 
            For Each childitem As GridDataItem In gridTableView.Items 
 
 
                childitem.Edit = True 
            Next 
            gridTableView.Rebind() 
 
 
        End If 
    Next 
End Sub 
 



Thanks
Princy
Tags
Grid
Asked by
Murray
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Murray
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or