change the value of a cell with jQuery

Hi

How to change the value of a cell with jQuery.

I want to change the value of a cell when a button is clicked.

I tried to do it with setCellValue but it didn't work.


1 Reply

RR Rajapandi Ravi Syncfusion Team November 27, 2023 09:17 AM UTC

Hi Alireza,


Greetings from Syncfusion support


After reviewing your query, we could see that you like to change the value of the cell and while tried with setCellValue it didn’t work. Based on your query we have prepared a sample and tried to reproduce your reported problem at our end, but it was unsuccessful. Please refer the below code example and sample for more information.


Index.cshtml

 

<script>

    document.getElementById("button").addEventListener("click", () => { //button click event

        var grid = document.getElementsByClassName('e-grid')[0].ej2_instances[0];

        grid.setCellValue(10002, "CustomerID", "Modified");

    });

 

</script>

 


Sample:


API: https://ej2.syncfusion.com/documentation/api/grid/#setcellvalue


We would like to inform you that, we have used setCellValue method to update the values in cell. It changes the value only in UI and does not affect the dataSource. If you want to change the value in both UI and dataSource, then you need to use updateRow method. Please refer the below API for more information.


API: https://ej2.syncfusion.com/documentation/api/grid/#updaterow


If still you have any issue, please share the below details that would be helpful for us to provide better solution.


1)               Share your complete Grid rendering code.


2)               Share the details about what type of edit mode (Normal/Batch/Dialog) you are using in your application.


3)               Share your Syncfusion package version.


Regards,

Rajapandi R


Attachment: 185577_cd3aad35.zip

Loader.
Up arrow icon