I am making a jqgrid using datatype local – a json array returned from the server.
jQuery("#my_table").jqGrid(
{ datatype: "local",
colNames: ['ID', 'Name','Status', 'Date'],
colModel:[ {name:'id',index:'id', width:50, sorttype:"int"},
{name:'name',index:'name', sorttype:"string"},
{name:'status',index:'status', width:50, sorttype:"string"},
{name:'date',index:'date', width:120, align:"left",sorttype:"date"} ],
data: result,
...});
However, one of the columns – status – is represented as numbers.
I would like to display this data as the respective strings. For example ‘Active’ for status = 1 and ‘Inactive’ for status = 0.
Is it possible to do this directly in jqgrid, for example as additional colModel parameter or jqgrid method?
I have read through the documentation of jqgrid and failed to notice way of addressing this problem.
I don’t want to change the data returned from the server, as I don’t see any point in passing redundant information.
I would also prefer if I don’t have to manipulate the result array in javascript directly as I don’t see point in traversing the array 2 times (once to change the status and the second for jqgrid loading).
You can use formatter: “select”: