RadGrid batch edit mode multiple grids incorrect command type

1 posts, 0 answers
  1. Kathleen Johnson
    Kathleen Johnson avatar
    8 posts
    Member since:
    Apr 2009

    Posted 21 Jul 2017 Link to this post

    Hello, I have two grids on the same page in batch edit mode. When I submit a page via javascript code the second grid has command type of "Update" instead of "Insert". Please help!

    <div class="grid__col grid__col--1-of-2">
                    <p>Prescriptions</p>
                    <telerik:RadGrid ID="gridPrescriptions" runat="server" AutoGenerateColumns="false"
                        AllowAutomaticInserts="true" AllowAutomaticUpdates="true" AllowSorting="True" AllowPaging="True"
                        OnNeedDataSource="gridPrescriptions_NeedDataSource" Width="100%" DataKeyNames="EscalationCaseRxId"
                        OnBatchEditCommand="gridPrescriptions_BatchEditCommand">
                        <MasterTableView CommandItemDisplay="Top" EditMode="Batch">
                            <BatchEditingSettings EditType="Row" />
                            <CommandItemSettings ShowSaveChangesButton="false" ShowRefreshButton="false" ShowCancelChangesButton="false" />
                            <Columns>
                                <telerik:GridBoundColumn DataField="RxNumber" HeaderText="Prescription Number *" UniqueName="RxNumber" MaxLength="50" HeaderStyle-Width="300">
                                    <ColumnValidationSettings EnableRequiredFieldValidation="true">
                                        <RequiredFieldValidator ForeColor="Red" Text="*This field is required" runat="server">
                                        </RequiredFieldValidator>
                                    </ColumnValidationSettings>
                                </telerik:GridBoundColumn>
                                <telerik:GridDateTimeColumn DataField="DateOfService" HeaderText="Date of Service *" UniqueName="DateOfService" HeaderStyle-Width="400" DataFormatString="{0:MM/dd/yyyy}">
                                    <ColumnValidationSettings EnableRequiredFieldValidation="true">
                                        <RequiredFieldValidator ForeColor="Red" Text="*This field is required" runat="server">
                                        </RequiredFieldValidator>
                                    </ColumnValidationSettings>
                                </telerik:GridDateTimeColumn>
                            </Columns>
                        </MasterTableView>
                    </telerik:RadGrid>
                </div>
     
                <div class="grid__col grid__col--1-of-2">
                    <p>Benefit Verification</p>
                    <telerik:RadGrid ID="gridBenefitVerification" runat="server" AutoGenerateColumns="false"
                        AllowAutomaticInserts="true" AllowAutomaticUpdates="true" AllowSorting="false" AllowPaging="True"
                        OnNeedDataSource="gridBenefitVerification_NeedDataSource" Width="100%" DataKeyNames="EscalationCaseBvId" OnBatchEditCommand="gridBenefitVerification_BatchEditCommand">
                        <MasterTableView CommandItemDisplay="Top" EditMode="Batch">
                            <BatchEditingSettings EditType="Row" />
                            <CommandItemSettings ShowSaveChangesButton="false" ShowRefreshButton="false" ShowCancelChangesButton="false" />
                            <Columns>
                                <telerik:GridDateTimeColumn DataField="DateVerified" HeaderText="Date Benefit Verified*" UniqueName="DateVerified" HeaderStyle-Width="400" DataFormatString="{0:MM/dd/yyyy}">
                                    <ColumnValidationSettings EnableRequiredFieldValidation="true">
                                        <RequiredFieldValidator ForeColor="Red" Text="*This field is required" runat="server">
                                        </RequiredFieldValidator>
                                    </ColumnValidationSettings>
                                </telerik:GridDateTimeColumn>
                            </Columns>
                        </MasterTableView>
                    </telerik:RadGrid>
                </div>
     
    function saveChanges() {
                    if (Page_IsValid) {
                        <%--var grid = $find("<%= gridPrescriptions.ClientID %>");
                        if (grid.get_masterTableView().get_dataItems().length > 0) {
                            grid.get_batchEditingManager().saveChanges(grid.get_masterTableView());
                        }
                        else {
                            var label = document.getElementById("<%= lblMessage.ClientID%>");
                            label.innerText = "Please add at least one prescription.";
                            label.style.color = "red";
                            label.style.display = "";
                            document.body.scrollTop = document.documentElement.scrollTop = 0;
                        }--%>
     
                        var gridRx = $find("<%= gridPrescriptions.ClientID %>");
                        var masterTableRx = gridRx.get_masterTableView();
     
                        if (masterTableRx.get_dataItems().length > 0) {
     
                            var gridBv = $find("<%= gridBenefitVerification.ClientID %>");
                            var masterTableBv = gridBv.get_masterTableView();
                            var batchEditManager = gridBv.get_batchEditingManager();
                            var tables = [];
     
                            //var changes1 = batchEditManager._changes;
                            //var changes2 = gridRx.get_batchEditingManager()._changes;
     
                            tables.push(masterTableRx);
                            tables.push(masterTableBv);
     
                            batchEditManager.saveTableChanges(tables);
                        }
                        else
                        {
                            var label = document.getElementById("<%= lblMessage.ClientID%>");
                            label.innerText = "Please add at least one prescription.";
                            label.style.color = "red";
                            label.style.display = "";
                            document.body.scrollTop = document.documentElement.scrollTop = 0;
                        }
                    }
                }

     

     

Back to Top