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

radGrid BatchEdit OnBatchEditCommand not fired for DetailTables

2 Answers 226 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 03 Oct 2013, 10:49 AM

I have a radGrid with a Master-Child-Relation and Edit mode is set to Batch.
The data will be populated via OnNeedDataSource for the master and via OnDetailTableDataBind.
The master table columns are readonly; the child columns not.
I would like to process data changes in the OnBatchEditCommand but the detail changes were not submitted.
(The e.Commands-collection has no members).

Any ideas ?

Thanks in advance.

The example show a simple Role/UsersInRole relationship.

<telerik:RadGrid ID="RadGrid2" runat="server"

 AutoGenerateColumns="False"

 CellSpacing="0"

 CellPadding="0"

 GridLines="None"

 MasterTableView-EditMode="Batch"

 Width="350px"

 AllowMultiRowEdit="true"

 OnNeedDataSource="RadGrid2_NeedDataSource"

 OnBatchEditCommand="RadGrid2_BatchEditCommand"

 OnDetailTableDataBind="RadGrid2_DetailTableDataBind">

 <MasterTableView

 DataKeyNames="Rolename"

 EditMode="Batch"

 CommandItemDisplay="Top"

 HierarchyDefaultExpanded="true"

 ExpandCollapseColumn-Visible="true"

 GroupsDefaultExpanded="true">

 <RowIndicatorColumn>

 <HeaderStyle Width="20px"></HeaderStyle>

 </RowIndicatorColumn>

 <ExpandCollapseColumn Visible="true" >

 <HeaderStyle Width="20px"></HeaderStyle>

 </ExpandCollapseColumn>

 <CommandItemSettings ShowSaveChangesButton="true" ShowCancelChangesButton="true" ShowAddNewRecordButton="false" ShowRefreshButton="false"/>

 <Columns>

 <telerik:GridBoundColumn UniqueName="Rolename" DataField="Rolename" HeaderText="Role"></telerik:GridBoundColumn>

 </Columns>

 <DetailTables>

 <telerik:GridTableView runat="server"

 Name="Detail"

 AutoGenerateColumns="false"

 DataKeyNames="Username"

 Width="100%"

 EditMode="Batch"

 ShowHeader="false"

 ShowFooter="false"

 AllowPaging="false"

 AllowFilteringByColumn="false"

 GridLines="None"

 BorderStyle="None"

 BatchEditingSettings-EditType="Cell">

 <ParentTableRelation>

 <telerik:GridRelationFields

 DetailKeyField="Rolename"

 MasterKeyField="Rolename" />

 </ParentTableRelation>

 <Columns>

 <telerik:GridBoundColumn UniqueName="Rolename" DataField="Rolename" HeaderText="Role" Display="false"></telerik:GridBoundColumn>

 <telerik:GridBoundColumn UniqueName="Username" DataField="Username" HeaderText="User"></telerik:GridBoundColumn>

 </Columns>

 </telerik:GridTableView>

 </DetailTables>

 </MasterTableView>
</telerik:RadGrid>

 

 

 

protected void RadGrid2_BatchEditCommand(object sender, GridBatchEditingEventArgs e)
{
   // e.Commands has no items for changes made in detail view
   foreach (GridBatchEditingCommand command in e.Commands)
   {
      Hashtable newValues = command.NewValues;
      Hashtable oldValues = command.OldValues;
      string OldRolename = oldValues["Rolename"].ToString();
      string NewRolename = newValues["Rolename"].ToString();
 
      // processing values
 
   }
}
 
protected void RadGrid2_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
   if (!e.IsFromDetailTable)
      {
         RadGrid2.DataSource = GetRoles();
      }
}
 
protected void RadGrid2_DetailTableDataBind(object sender, GridDetailTableDataBindEventArgs e)
{
   var parentItem = e.DetailTableView.ParentItem as GridDataItem;
   if (e.DetailTableView.Name == "Detail")
   {
      string Rolename = parentItem.GetDataKeyValue("Rolename").ToString();
      e.DetailTableView.DataSource = GetUsersInRole(Rolename);
   }
}

 

2 Answers, 1 is accepted

Sort by
0
Angel Petrov
Telerik team
answered on 08 Oct 2013, 06:52 AM
Hello Michael,

Generally you should not experience such behavior. Is the problem related to the one described in the official support ticket you have opened regarding this matter? If that is the case I would like to ask you to share your findings with the community so others can benefit from them.

Regards,
Angel Petrov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Michael
Top achievements
Rank 1
answered on 08 Oct 2013, 07:35 AM
Hi Angel,
updating to the new Verions (2013.3.926.40 solved the problem.
Now the BatchEditCommand-event is fired for each of the detail tables.
Thanks a lot for your help!

Best regards,
Michael
Tags
Grid
Asked by
Michael
Top achievements
Rank 1
Answers by
Angel Petrov
Telerik team
Michael
Top achievements
Rank 1
Share this question
or