We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Using updateRecord with Batch Edit mode

Hi Team,

I have a grid that uses batch edit mode and button that uses updateRecord for the said grid. The problem is getting the new data that is updated both using the updateRecord function and updates from user input.  If I use a batchSave and getCurrentViewData the data that I get are only those changes made by the user as if the data from the updateRecord is disregarded. If I check the data using getBatchChanges, it would show the former data of the record where updateRecord was used.
Original Data
PKId = 1
ShipQty = 1
Unit = "PACK"
Factor = 25
OrigQty = 25
Description = "Jevity"

function UpdateRecord(pkId){
 $("#ShipmentGrid").ejGrid("updateRecord", "PKId", {
        "PKId": pkId,      
        "ShipQty": 5,
        "Unit": "CASE",
         "Factor": 5,
         "OrigQty": 25,
        "Description": "Jevity",
    });
}

Then user changed ShipQty to '7'

Data Displayed on Grid:
PKId = 1
ShipQty = 7
Unit = "CASE"
Factor = 5
OrigQty = 25
Description = "Jevity"

var grid = $("#ShipmentGrid").data("ejGrid");
var shipData = grid._currentJsonData;  <--- at this point ShipQty = 5, Unit = 'CASE'

$("#ShipmentGrid").ejGrid("batchSave");
var grid = $("#ShipmentGrid").data("ejGrid");
 var shipData = grid._currentJsonData;   <--- at this point ShipQty = 7 but Unit = 'PACK'

What I need to get from shipData is the one that is on display, that is ShipQty = 7, Unit = 'CASE'

Is there a way to simply get the data that is displayed on the grid? or update the record that would reflect after a batchSave?


Thanks




1 Reply

SR Sellappandi Ramu Syncfusion Team October 21, 2015 08:58 AM UTC

Hi Lory,

Thanks for contacting Syncfusion support.

We can get only the modified data before batchSave using getBatchChanges(). After batchSave, we can get the current data using getCurrentViewData().

Please refer to the code example and sample for your requirement,

    <button id="CellChange">Current value</button>

    <div id="Grid"></div>

    <script type="text/javascript">

        $(function () {

            $("#Grid").ejGrid({

                dataSource: window.gridData,

                allowPaging: true,

                                   ….

                columns: [

                                                                …..

                ]

            });

            $("#UpdateButton").ejButton({

                click: "UpdateRecord",

            });

        });

        function UpdateRecord() {

            $("#Grid").ejGrid("updateRecord", "OrderID", {

                "OrderID": 10248,

                "CustomerID": "Tomps",

                "EmployeeID": 3,

                "Freight": 5,

                "ShipName": "Toms Speziliation",

                "ShipCountry": "Itally",

            });

obj = $("#Grid").ejGrid("instance");

obj._bulkEditCellDetails._data = $.extend(true, [], obj.getCurrentViewData());//Setting the data from currentViewData for data reflect in edit form

        }


Sample: http://jsplayground.syncfusion.com/ysjkpxvj

In the above sample, we have used Update button to update the dynamic data in grid. After the date updated, we can get the current page data using getCurrentViewData() or model.currentViewData.

Regards,
Sellappandi R

Loader.
Live Chat Icon For mobile
Up arrow icon