jqgrid的formatter和unformat

@admin  December 28, 2016
jQuery("#grid_id").jqGrid({  
...  
   colModel: [   
      ...   
      {name:'price', index:'price', width:60, align:"center", editable: true, formatter:imageFormat, unformat:imageUnFormat},  
      ...  
   ]  
...  
});  
   
function imageFormat( cellvalue, options, rowObject ){  
    return '<img src="'+cellvalue+'" />';  
}  
function imageUnFormat( cellvalue, options, cell){  
    return $('img', cell).attr('src');  
}  

上述代码在表格中显示图片,编辑时显示图片链接


添加新评论