You can change the cell value in a jqGrid by using the setCell
method. This method allows you to set the value of a specific cell programmatically.
Here's an example of how to use the setCell
method to change the value of a cell:
javascript// Set the value of the cell in row with id="1" and column with name="columnName"
$("#grid").jqGrid('setCell', '1', 'columnName', 'new value');
In this example, we're using the setCell
method to set the value of a cell in row with id "1"
and column with name "columnName"
to "new value"
. You can replace "1"
, "columnName"
, and "new value"
with the appropriate values for your grid.
Note that the setCell
method only updates the cell value in the client-side grid. If you need to save the new value to the server, you'll need to use the saveCell
method after calling setCell
. The saveCell
method saves the edited cell to the server and updates the grid with any changes that may have occurred.
Here's an example of how to use setCell
and saveCell
together:
javascript// Set the value of the cell in row with id="1" and column with name="columnName"
$("#grid").jqGrid('setCell', '1', 'columnName', 'new value');
// Save the edited cell to the server
$("#grid").jqGrid('saveCell', '1', 'columnName');
In this example, we're first calling setCell
to update the cell value, and then calling saveCell
to save the edited cell to the server.
Comments
Post a Comment