我是 jqGrid 的新手,我正在使用 jqGrid-4.4.0 使用 Spring MVC 显示来自 db2 数据库的值。我已经使用格式化程序选项来根据其中一列的值显示图像,这也可以正常工作。问题是,当我双击要编辑的行而不是从列中获取值时,我得到了图像 html 标记。如何显示从数据库中获得的实际值?
下面是我用来格式化的函数
function imageFormat( cellvalue, options, rowObject ){
var img="";
if(cellvalue==true){
img= "<img src='"+CONTEXT_ROOT+"/images/icons/Light_Green_Round_16_n_g.gif' BORDER='0'/>";
}else{
img= "<img src='"+CONTEXT_ROOT+"/images/icons/Light_Red_Round_16_n_g.gif' BORDER='0'/>";
}
return img;
}
在 colModel 我正在调用该函数
colModel:[
{name:'idCasePackOptions',hidden:true,editrules:{edithidden:true, required:false}, editable:true},
{name:'cypharecommended',index:'cypharecommended', width:170, sorttype:"int", sortable:true, editable:true, edittype:'checkbox', editoptions: { value:"1:0" }},
{name:'distributorapproved',index:'distributorapproved', width:170, sorttype:"int", edittype:'text', editable:true, sortable:true},
{name:'height',index:'height', width:100, sorttype:"float", edittype:'text', editable:true,sortable:true},
{name:'length',index:'length', width:80, align:"right",sorttype:"float", edittype:'text', editable:true, sortable:true},
{name:'statuscode',index:'statuscode', width:90, align:"right", edittype:'text', editable:true,sorttype:"int", sortable:true, formatter:imageFormat},
{name:'weight',index:'weight', width:100,align:"right", edittype:'text', editable:true,sorttype:"float", sortable:true},
{name:'width',index:'width', width:100, editable:true, edittype:'text', sorttype:"float",sortable:true}
]