RadGrid Batch edit not working

2 posts, 0 answers
  1. Tom
    Tom avatar
    2 posts
    Member since:
    Apr 2016

    Posted 11 May Link to this post

    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">          
                 <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>             
                 <uc:Forecast runat="server" ID="Forecast" Visible="false"/>

    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" />
                       <telerik:GridBoundColumn DataField="Type" HeaderText="" UniqueName="ForecastType" FooterText="Total Sales">                      
                       <telerik:GridBoundColumn DataField="1" HeaderText="Jan" UniqueName="Jan" Aggregate="Sum" FooterText=" ">
                               <ModelErrorMessage Text="" />
                       <telerik:GridBoundColumn DataField="2" HeaderText="Feb" UniqueName="Feb" Aggregate="Sum" FooterText=" ">
                               <ModelErrorMessage Text="" />
               <ClientSettings AllowKeyboardNavigation="true"></ClientSettings>

  2. Viktor Tachev
    Viktor Tachev avatar
    1438 posts

    Posted 16 May Link to this post

    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.

    Viktor Tachev
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. DevCraft R3 2016 release webinar banner
Back to Top