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

RadGrid Batch edit not working

1 Answer 295 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tom
Top achievements
Rank 1
Tom asked on 11 May 2016, 02:40 PM

I have a RadGrid that when a row is expanded loads up another user control with a RadGride inside, like so:

  

<telerik:RadGrid OnItemCommand="RadGridList_ItemCommand" ID="RadGridList" Width="100%" runat="server" AllowPaging="True" AllowSorting="True"OnSortCommand="RadGridList_SortCommand" OnNeedDataSource="RadGridList_NeedDataSource"     AutoGenerateHierarchy="True" GroupPanelPosition="Top" ShowFooter="False" PageSize="10" CellSpacing="0" >
     <MasterTableView AutoGenerateColumns="False" AllowMultiColumnSorting="True" GroupLoadMode="Server" EditMode="Batch">          
         <Columns>
             <telerik:GridBoundColumn DataField="CompanyID" HeaderText="Company ID" UniqueName="CompanyID" Display="false"></telerik:GridBoundColumn>               
            <telerik:GridBoundColumn DataField="1" HeaderText="Jan" UniqueName="Jan"></telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="2" HeaderText="Feb" UniqueName="Feb"></telerik:GridBoundColumn>              
             <telerik:GridBoundColumn DataField="3" HeaderText="Mar" UniqueName="Mar"></telerik:GridBoundColumn>             
         </Columns>
         <NestedViewTemplate>
             <uc:Forecast runat="server" ID="Forecast" Visible="false"/>
         </NestedViewTemplate>
     </MasterTableView>
 </telerik:RadGrid>

The nested user control is data bound when the 'ExpandCollapse' item command is fired. When I set EditMode="Batch" in the top level RadGrid it works fine, but I cannot get it to work in the nested RadGrid. The 'Add', 'Save', 'Cancel' and 'Refresh' buttons all appear and fire events, but the cells in the grid don't become editable on click.

 

Here is the code for the Forecast user control RadGrid:

 

<telerik:RadGrid ID="RadGridForecast" runat="server" OnNeedDataSource="RadGridForecast_NeedDataSource" AllowSorting="True" CssClass="radGridForecast"ShowFooter="True" GridLines="None" CellSpacing="0" AllowAutomaticUpdates="True" AllowAutomaticInserts="True" AllowAutomaticDeletes="True"           OnItemUpdated="RadGridForecast_ItemUpdated" OnSortCommand="RadGridForecast_SortCommand" OnBatchEditCommand="RadGridForecast_BatchEditCommand" >         
    <MasterTableView CommandItemDisplay="Bottom" AutoGenerateColumns="False" GroupLoadMode="Server" EditMode="Batch">
               <BatchEditingSettings OpenEditingEvent="Click" EditType="Cell" />
               <Columns>
                   <telerik:GridBoundColumn DataField="Type" HeaderText="" UniqueName="ForecastType" FooterText="Total Sales">                      
                   </telerik:GridBoundColumn>
                   <telerik:GridBoundColumn DataField="1" HeaderText="Jan" UniqueName="Jan" Aggregate="Sum" FooterText=" ">
                       <ColumnValidationSettings>
                           <ModelErrorMessage Text="" />
                       </ColumnValidationSettings>
                   </telerik:GridBoundColumn>
                   <telerik:GridBoundColumn DataField="2" HeaderText="Feb" UniqueName="Feb" Aggregate="Sum" FooterText=" ">
                       <ColumnValidationSettings>
                           <ModelErrorMessage Text="" />
                       </ColumnValidationSettings>
                   </telerik:GridBoundColumn>                   
               </Columns>               
           </MasterTableView>
           <ClientSettings AllowKeyboardNavigation="true"></ClientSettings>
       </telerik:RadGrid>

Thanks!

1 Answer, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 16 May 2016, 07:14 AM
Hi Tom,

The RadGrid supports hierarchy in Batch Edit mode. You should add the child table in the DetailTables collection of the grid. The approach would be similar to the one in the following example.


In order to save all hierarchy levels when the SaveChanges button is clicked you should set the MasterTableView-BatchEditingSettings-SaveAllHierarchyLevels property to true.


Regards,
Viktor Tachev
Telerik
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
Grid
Asked by
Tom
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Share this question
or