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.
Unfortunately, activation email could not send to your email. Please try again.

Using updateRecord with Batch Edit mode

Thread ID:

Created:

Updated:

Platform:

Replies:

120831 Oct 20,2015 12:01 PM Oct 21,2015 04:58 AM JavaScript 1
loading
Tags: ejGrid
Lory
Asked On October 20, 2015 12:01 PM

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




Sellappandi Ramu [Syncfusion]
Replied On October 21, 2015 04:58 AM

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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;