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

RadGrid with both Hierarchy AND Multi-row edit?

2 Answers 69 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Erik
Top achievements
Rank 1
Erik asked on 20 Aug 2010, 11:46 PM
I would like to be able to use Hierarchy mode to create several subgrids, which I have working fine.  I need, however, to enable multi-row editing on the rows in the bottom level grids. 

The problem I'm seeing is there appears to be no way to get just the items in the bottom selected grid.  I have tried waling the DetailTable.s, and those are empty, even though I have multiple rows.  I've tried the following code, and it doesn't work.  MasterTableView.Items contains my 6 top-level items.  the FirstDetailTables(0) has a count of 0 even though there is one item in it, and the second also has a count of 0 and has several items.  I have 3 total levels in my heirarchy.

foreach (GridItem item in RadGrid1.MasterTableView.DetailTables[0].DetailTables[0].Items)
{
    item.Edit = true;
}
RadGrid1.MasterTableView.DetailTables[0].DetailTables[0].Rebind();

Any help here?

Some additional information:

I have tried using RadGrd1.HierarchyItems and checking if there are no children and if true, enabling edit but that gives... weird results.

Also, I am using a CommandItemTemplate in my final GridTableView with an "Edit" button, which sends the command EditMode to the grids ItemCommand event handler, and that's where I call the above code.

I have also enabled AllowMultiRowEdit on the grid, and i'm not using Ajax if that matters.

2 Answers, 1 is accepted

Sort by
0
Erik
Top achievements
Rank 1
answered on 23 Aug 2010, 08:49 PM
Any Suggestions?
0
Princy
Top achievements
Rank 2
answered on 25 Aug 2010, 09:01 AM
Hello Erik,

You can try the following method to to enable multi-row editing on the rows in the bottom level grids. 
 
ASPX:
<DetailTables>
   <telerik:GridTableView CommandItemDisplay="Top">
        <CommandItemTemplate>
           <asp:Button ID="Button2" runat="server" Text="Edit" CommandName="EditAllDetailTableItems"  />
        </CommandItemTemplate>
   </telerik:GridTableView>
</DetailTables>

C#:
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
   {
       if (e.CommandName == "EditAllDetailTableItems")
       {
           GridCommandItem cmditem = (GridCommandItem)e.Item;
           GridTableView tableView = (GridTableView)cmditem.NamingContainer.Parent.Parent;
           foreach (GridDataItem item in tableView.Items)
              item.Edit = true;
           tableView.Rebind();
       }
   }

Thanks,
Princy.
Tags
Grid
Asked by
Erik
Top achievements
Rank 1
Answers by
Erik
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or