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

Putting hierarchical grid detail table rows into edit mode

1 Answer 108 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rob
Top achievements
Rank 1
Rob asked on 17 Sep 2010, 04:05 PM
I have a simple two level hierarchical grid that has all items expanded in the PreRender event. This works fine.

What I'd like to do now is put all items in the detail table into edit mode.

Originally this was a flat grid and I used the grid's EditIndexes() array to add each data item's index as part of the grid's NeedDataSource event, however I can't find how to do this for a detail table. I tried mygrid.MasterTableView.DetailTables[0], but there's no EditIndexes() collection on the DetailTable.

Any suggestions?

Rob

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 18 Sep 2010, 05:20 AM
Hello Rob,

Try the following code snippet in PreRender event to put all the DetailTable items in edit mode.

C#:
protected void RadGrid1_PreRender(object sender, EventArgs e)
   {
      if (!IsPostBack)
       {
           foreach (GridDataItem item in RadGrid1.MasterTableView.Items)
           {
               item.Expanded = true;
               GridTableView tableView = (GridTableView)item.ChildItem.NestedTableViews[0];
               foreach (GridItem childItem in tableView.Items)
               {
                   if (childItem is GridEditableItem)
                   {
 
                       GridEditableItem editableItem = childItem as GridDataItem;
                       editableItem.Edit = true;
                   }
               }
               tableView.Rebind();
           }
       }
   }

Note: Set AllowMultiRowEdit  property of RadGrid to "True" to enable multi-row editing.

-Shinu.
Tags
Grid
Asked by
Rob
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or