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

Why!! RadGrid BatchEdit 3 Grid on 1 Page Not Work

3 Answers 73 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Supaporn
Top achievements
Rank 1
Supaporn asked on 23 Jun 2016, 03:32 AM

- 2 Grid on 1 Page it Work
- 3 Grid on 1 Page Not Work. 

>> RadGrid  working to Grid1_BatchEditCommand and Grid3_BatchEditCommand Not working to Grid2_BatchEditCommand <<

 

<head>
    <title>Test</title>
    <script type="text/javascript">
 
         function SaveGrid(sender, args) {
 
            var grid1 = $find('<%=RadGrid1.ClientID%>');
            var grid1changes = grid1.get_batchEditingManager()._extractChangesString(grid1.get_masterTableView());
            if (grid1changes.length > 0) {
                grid1.get_masterTableView().fireCommand("BatchEdit", grid1changes);
            }
 
            var grid2 = $find('<%= RadGrid2.ClientID%>');
            var grid2changes = grid2.get_batchEditingManager()._extractChangesString(grid2.get_masterTableView());
            if (grid2changes.length > 0) {
                 grid2.get_masterTableView().fireCommand("BatchEdit", grid2changes);
            }
 
            var grid3 = $find('<%= RadGrid3.ClientID%>');
            var grid3changes = grid3.get_batchEditingManager()._extractChangesString(grid3.get_masterTableView());
            if (grid3changes.length > 0) {
                grid3.get_masterTableView().fireCommand("BatchEdit", grid3changes);
            }
 
        }
 
    </script>
</head>
<body>
    <form id="Form1" runat="server">
        <telerik:RadScriptManager Runat="server"></telerik:RadScriptManager>
           
           
        <telerik:RadButton runat="server" ID="RadButton1" Text="SaveAllChanges" AutoPostBack="false" OnClientClicked="SaveGrid"></telerik:RadButton>
   
           
        <telerik:GridNumericColumnEditor ID="NumericEditor1" runat="server">
            <NumericTextBox ID="NumericTextBox1" runat="server" Width="60px" />
        </telerik:GridNumericColumnEditor>
           
        <telerik:GridTextBoxColumnEditor runat="server" ID="TextEditor">
            <TextBoxStyle Width="120px" />
        </telerik:GridTextBoxColumnEditor>
   
        <!--Grid1------------>
 
        <telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="SqlDataSource3"
            AllowPaging="True" AllowAutomaticUpdates="True" AllowAutomaticInserts="True"
            AllowAutomaticDeletes="true" AllowSorting="true" PageSize="3" >
            <PagerStyle Mode="NextPrevAndNumeric" />
            <MasterTableView DataSourceID="SqlDataSource3" AutoGenerateColumns="False"
                DataKeyNames="CustomerID" EditMode="Batch" CommandItemDisplay="Top">
                <Columns>
        
                    <telerik:GridBoundColumn DataField="CustomerID" HeaderText="CustomerID" SortExpression="CustomerID"
                        UniqueName="CustomerID">
                    </telerik:GridBoundColumn>
   
   
                   <telerik:GridTemplateColumn HeaderText="ContactName" HeaderStyle-Width="180px" UniqueName="ContactName" >
                        <ItemTemplate>
                            <%# Eval("ContactName") %>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="TextBox1" Text='<%# Bind("ContactName") %>' runat="server"></asp:TextBox>
                        </EditItemTemplate>
                    </telerik:GridTemplateColumn>
   
   
                    <telerik:GridBoundColumn DataField="CompanyName" HeaderText="CompanyName" SortExpression="CompanyName"
                        UniqueName="CompanyName">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="ContactTitle" HeaderText="ContactTitle" SortExpression="ContactTitle"
                        UniqueName="ContactTitle">
                    </telerik:GridBoundColumn>
                
   
                       
                 <telerik:GridBoundColumn DataField="Phone" HeaderStyle-Width="135px" HeaderText="Quantity Per Unit"
                        SortExpression="" ColumnEditorID="TextEditor" UniqueName="QuantityPerUnit">
                    </telerik:GridBoundColumn>
   
   
                    <telerik:GridButtonColumn Text="Delete" CommandName="Delete" ButtonType="ImageButton" />
                </Columns>
            </MasterTableView>
        </telerik:RadGrid>
   
     
        <!--Grid2------------>
   
        <telerik:RadGrid ID="RadGrid2" GridLines="None" runat="server" AllowAutomaticDeletes="True"
            AllowAutomaticInserts="True" PageSize="3" Skin="Default" AllowAutomaticUpdates="True" AllowPaging="True"
            AutoGenerateColumns="False" Width="750px" DataSourceID="SqlDataSource1">
   
            <MasterTableView CommandItemDisplay="TopAndBottom" DataKeyNames="ProductID"
                DataSourceID="SqlDataSource1" HorizontalAlign="NotSet" EditMode="Batch" AutoGenerateColumns="False">
                <BatchEditingSettings EditType="Cell" />
                <SortExpressions>
                    <telerik:GridSortExpression FieldName="ProductID" SortOrder="Descending" />
                </SortExpressions>
                <Columns>
                    <telerik:GridBoundColumn DataField="ProductName" HeaderStyle-Width="210px" HeaderText="ProductName" SortExpression="ProductName"
                        UniqueName="ProductName">
                        <ColumnValidationSettings EnableRequiredFieldValidation="true">
                            <RequiredFieldValidator ForeColor="Red" Text="*This field is required">
                            </RequiredFieldValidator>
                        </ColumnValidationSettings>
                    </telerik:GridBoundColumn>
                    <telerik:GridTemplateColumn HeaderText="Category" HeaderStyle-Width="180px" UniqueName="CategoryID" DataField="CategoryID">
                        <ItemTemplate>
                            <%# Eval("CategoryName") %>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <telerik:RadDropDownList runat="server" ID="CategoryIDDropDown" DataValueField="CategoryID"
                                DataTextField="CategoryName" DataSourceID="SqlDataSource2">
                            </telerik:RadDropDownList>
                        </EditItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridNumericColumn DataField="UnitsInStock" HeaderStyle-Width="80px"
                        ColumnEditorID="NumericEditor1" HeaderText="Units In Stock" SortExpression="UnitsInStock"
                        UniqueName="UnitsInStock">
                    </telerik:GridNumericColumn>
                    <telerik:GridBoundColumn DataField="QuantityPerUnit" HeaderStyle-Width="135px" HeaderText="Quantity Per Unit"
                        SortExpression="QuantityPerUnit" ColumnEditorID="TextEditor" UniqueName="QuantityPerUnit">
                    </telerik:GridBoundColumn>
                    <telerik:GridCheckBoxColumn DataField="Discontinued" HeaderStyle-Width="80px" HeaderText="Discontinued" SortExpression="Discontinued"
                        UniqueName="Discontinued">
                    </telerik:GridCheckBoxColumn>
                    <telerik:GridTemplateColumn HeaderText="UnitPrice" ColumnEditorID="NumericEditor1"
                        HeaderStyle-Width="80px" SortExpression="UnitPrice" UniqueName="TemplateColumn"
                        DataField="UnitPrice">
                        <ItemTemplate>
                            <asp:Label runat="server" ID="lblUnitPrice" Text='<%# Eval("UnitPrice", "{0:C}") %>'></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <span>
                                <telerik:RadNumericTextBox Width="55px" runat="server" ID="tbUnitPrice">
                                </telerik:RadNumericTextBox>
                                <span style="color: Red">
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1"
                                        ControlToValidate="tbUnitPrice" ErrorMessage="*Required" runat="server">
                                    </asp:RequiredFieldValidator>
                                </span>
                            </span>
                        </EditItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridButtonColumn ConfirmText="Delete this product?" ConfirmDialogType="RadWindow"
                        ConfirmTitle="Delete" HeaderText="Delete" HeaderStyle-Width="50px" ButtonType="ImageButton"
                        CommandName="Delete" Text="Delete" UniqueName="DeleteColumn">
                    </telerik:GridButtonColumn>
                </Columns>
            </MasterTableView>
        </telerik:RadGrid>
 
 
        <!--Grid3------------>
   
        <telerik:RadGrid ID="RadGrid3" GridLines="None" runat="server" AllowAutomaticDeletes="True"
            AllowAutomaticInserts="True" PageSize="3" Skin="Default" AllowAutomaticUpdates="True" AllowPaging="True"
            AutoGenerateColumns="False" Width="750px" DataSourceID="SqlDataSource1">
   
            <MasterTableView CommandItemDisplay="TopAndBottom" DataKeyNames="PersonID"
                DataSourceID="SqlDataSource1" HorizontalAlign="NotSet" EditMode="Batch" AutoGenerateColumns="False">
                <BatchEditingSettings EditType="Cell" />
                <SortExpressions>
                    <telerik:GridSortExpression FieldName="PersonID" SortOrder="Descending" />
                </SortExpressions>
                <Columns>
                    <telerik:GridBoundColumn DataField="PersonName" HeaderStyle-Width="210px" HeaderText="PersonName" SortExpression="PersonName"
                        UniqueName="PersonName">
                        <ColumnValidationSettings EnableRequiredFieldValidation="true">
                            <RequiredFieldValidator ForeColor="Red" Text="*This field is required">
                            </RequiredFieldValidator>
                        </ColumnValidationSettings>
                    </telerik:GridBoundColumn>
                    <telerik:GridTemplateColumn HeaderText="Position" HeaderStyle-Width="180px" UniqueName="PositionID" DataField="PositionID">
                        <ItemTemplate>
                            <%# Eval("PositionName")%>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <telerik:RadDropDownList runat="server" ID="PositionIDDropDown" DataValueField="PositionID"
                                DataTextField="PositionName" DataSourceID="SqlDataSource2">
                            </telerik:RadDropDownList>
                        </EditItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridNumericColumn DataField="PersonNickname" HeaderStyle-Width="80px"
                        ColumnEditorID="NumericEditor1" HeaderText="Nickname" SortExpression="Nickname"
                        UniqueName="Nickname">
                    </telerik:GridNumericColumn>
                    <telerik:GridBoundColumn DataField="PersonContract" HeaderStyle-Width="135px" HeaderText="Contract"
                        SortExpression="PersonContract" ColumnEditorID="TextEditor" UniqueName="PersonContract">
                    </telerik:GridBoundColumn>
                    <telerik:GridCheckBoxColumn DataField="PersonFundNumb" HeaderStyle-Width="80px" HeaderText="PersonFundNumb" SortExpression="PersonFundNumb"
                        UniqueName="PersonFundNumb">
                    </telerik:GridCheckBoxColumn>
                    <telerik:GridButtonColumn ConfirmText="Delete this product?" ConfirmDialogType="RadWindow"
                        ConfirmTitle="Delete" HeaderText="Delete" HeaderStyle-Width="50px" ButtonType="ImageButton"
                        CommandName="Delete" Text="Delete" UniqueName="DeleteColumn">
                    </telerik:GridButtonColumn>
                </Columns>
            </MasterTableView>
        </telerik:RadGrid>
   
</form
</body
 
<!-----------Behind Code ----------->
 
 Protected Sub Grid1_BatchEditCommand(sender As Object, e As GridBatchEditingEventArgs) Handles Grid1.BatchEditCommand
        If e.Commands.Count > 0 Then
            '.............................................
        End If
    End Sub
 
<!-----------Not Working Grid2_BatchEditCommand  ----------->
    Protected Sub Grid2_BatchEditCommand(sender As Object, e As GridBatchEditingEventArgs) Handles Grid2.BatchEditCommand
        If e.Commands.Count > 0 Then
            '.............................................
        End If
    End Sub
 
    Protected Sub Grid3_BatchEditCommand(sender As Object, e As GridBatchEditingEventArgs) Handles Grid3.BatchEditCommand
        If e.Commands.Count > 0 Then
            '.............................................
        End If
    End Sub

3 Answers, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 27 Jun 2016, 07:42 AM
Hi,

If you would like to save the changes in multiple RadGrid controls in Batch edit mode you should use the saveTableChanges() method. Note that you need to pass an array of all the GridTableViews that would be updated as argument.


Give the approach a try and you should be able to implement the behavior you are looking for.


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.
0
Supaporn
Top achievements
Rank 1
answered on 27 Jun 2016, 07:49 AM

Hi, Viktor Tachev

    I Use to saveTableChanges() but not Working and Error 

Link >> http://www.telerik.com/forums/bug!!-radgrid-batchedit-unable-to-get-property-'cell'-of-undefined-or-null-reference

0
Viktor Tachev
Telerik team
answered on 29 Jun 2016, 12:01 PM
Hello,

Did you try the suggestions from the other thread? What was the behavior after that?

With that said please send us a runnable sample where the problematic behavior you are observing is replicated. This will enable us to examine the issue and look for its cause.


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
Supaporn
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Supaporn
Top achievements
Rank 1
Share this question
or