I need to set the JQgrid cell value based on the condition, suppose the variable value is one then i need to set a bike, if it is 2 then i need to set as car, and so on.
Can anyone please explain how to achieve this?
I need to set the JQgrid cell value based on the condition, suppose the variable value is one then i need to set a bike, if it is 2 then i need to set as car, and so on.
Can anyone please explain how to achieve this?
You need to use formatter
to get the work done. Include this into following line and start developing the function.
Eg.
{name:'vehicle', index:'vehicle', width:100, align:"center", editable: true, formatter:formatvehicle}
Method Development:
function formatvehicle (cellvalue, options, rowObject)
{
if (cellvalue == 1)
return "Bike";
else if (cellvalue == 2)
return "Car";
else {
}
}
OR try using Switches.
function formatvehicle (cellvalue, options, rowObject) {
switch (cellvalue) {
case 1:
return "Bike";
break;
case 2:
return "Car";
break;
}
}
You can achieve this using the formatter
Reference: http://www.trirand.com/jqgridwiki/doku.php?id=wiki:custom_formatter