This question may have been asked many times, but I would like to know if it possible to dynamically change the cell value of a jqgrid?
I basically have a grid that is t
I would recommend you to use beforeProcessing
callback which is simple to use and which is very powerful. For example if you get the data from the server in the standard JSON format
{
"total": "xxx",
"page": "yyy",
"records": "zzz",
"rows" : [
{"id": "1", "cell": ["cell11", "null", "cell13"]},
{"id": "2", "cell": ["cell21", "cell22", null]},
...
]
}
you can do something like the following
beforeProcessing: function (data) {
var rows = data.rows, cRows = rows.length, row, iRow, cCol, iCol, cell;
for (iRow = 0; iRow < cRows; iRow++) {
row = rows[iRow].cell;
for (iCol = 0, cCol = row.length; iCol < cCol; iCol++) {
cell = row[iCol];
if (cell === null || cell === "null") {
row[iCol] = "Not Applicable";
}
}
}
}
In the way you can modify the data returned from the server before the data will be processed by the jqGrid.
I don't think that changing the value is what you really need in this situation. You should rather create your own custom formatter. It might look more less like this:
var nullFormatter = function(cellvalue, options, rowObject) {
if (cellValue == null)
return "Not Applicable";
else
return cellValue;
};
This is just very basic, sample implementation but it should give you an idea.