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

Update Cell

Hi Team,

I understand you could update a record in the grid using updateRecord(fieldName, data).
But is there a way to update just a single cell in the record? 

I have a inventory grid set on "batch" edit mode, and I want it set so that the value of one cell changes based on the value edited on the other.

Is that possible? Thanks



1 Reply

GV Gowthami V Syncfusion Team September 25, 2015 06:38 AM UTC

Hi Lory,

Thanks for contacting Syncfusion support.

We can achieve your requirement by using “setCellValue” method of the grid as follows,

<script type="text/javascript">

        $(function () {
            $("#Grid").ejGrid({
. . . .
. . . .
editSettings: { allowEditing: true, allowAdding: true, allowDeleting: true, editMode: "batch" },
. . . .
. . . .

cellSave: function (args) {

                    if (args.columnName == "EmployeeID" && args.value == 5) {

//Getting the index of the edited cell row

                        var index = this.getIndexByRow(args.cell.parent());

//Updating the cell value of the Freight column

                        this.setCellValue(index, "Freight", 0);

                       

                    }

                }

            });

        });
    </script>


We have created a sample with your requirement like editing the EmployeeID column cell has value “5” then the Freight column cell value will be updated as “0” using setCellValue method of the grid.

Please refer the below link for the sample demo,

http://jsplayground.syncfusion.com/flkkd10c

Regards,
Gowthami V.

Loader.
Live Chat Icon For mobile
Up arrow icon