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

How do I get editable child and grandchild rows

3 Answers 80 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jeremy
Top achievements
Rank 1
Jeremy asked on 22 Mar 2012, 03:44 PM
Currently, when I load a RadGrid, I'm able to get the parent rows to all be editable by using the following code in the PreRender event:
for (int i = 0; i < RadGrid1.PageSize; i++) {
    RadGrid1.EditIndexes.Add(i);
}
RadGrid1.Rebind();

However, my RadGrid has a self-heiracrchy and when I drop down to the next level, and all subsequent levels, those rows are read only.  But, the parents are still editable.

My question has two parts.  First, how can I get the children, grandchildren, etc. to be editable?  And, if I don't have paging enabled, how can I get these rows to be editable (i.e. RadGrid1.PageSize isn't set).

Thanks!!

Jeremy

3 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 22 Mar 2012, 05:23 PM
Hello,

By below you can access edit items of all grid.
<MasterTableView DataKeyNames="ID" Name="Parent">
               <DetailTables>
                   <telerik:GridTableView Name="child1">
foreach (GridEditableItem item in RadGrid1.EditItems)
            {
                if (item.OwnerTableView.Name == "Parent")
                {
                    // access edit for parent
                }
                else if (item.OwnerTableView.Name == "Child1")
                {
                    // access edit for child1
                }
            }


Thanks,
Jayesh Goyani
0
Jeremy
Top achievements
Rank 1
answered on 22 Mar 2012, 05:46 PM
Thanks, Jayesh.  However, I'm not trying to access those items.  I'm trying to make them editable.  Right now, only the parent items in the MasterTableView are editable.  I'm having a lot of difficulty getting the child items to be editable.  And the code I included above doesn't seem to work with the child items.

Jeremy
0
Jayesh Goyani
Top achievements
Rank 2
answered on 22 Mar 2012, 05:50 PM
Hello,

foreach (GridDataItem item in RadGrid1.MasterTableView.Items)
            {
                item.Edit = true;
                if (item.HasChildItems)
                {  
                    foreach (GridDataItem citem in item.ChildItem.NestedTableViews[0].Items)
                    {
                        citem.Edit = true;
                    }
                }
            }


Thanks,
Jayesh Goyani
Tags
Grid
Asked by
Jeremy
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Jeremy
Top achievements
Rank 1
Share this question
or