How to show image in jqgrid in edit mode
jqGrid contains image column defined using colmodel below. image id is passed in cell value from server in json. grid shows images properly if not in edit modes.
Inline and form edit mode show wrong image since editoptions src property contains fixed id 1
How to show image from editable row id in edit mode ? How to pass cell value to editoptions src property like in formatter function?
name:"Image",
edittype:"image",
editoptions:{ src: "G开发者_Go百科etImage?id=1"},
formatter:function(cell,options,row) {
return "<img src='GetImage?id=" + cell + "'/>"
}
I can suggest you to change the value of the src
property of the editoptions
immediately before staring editing. Look at the answer for details. In case of form editing you can use beforeInitData to modify src
:
beforeInitData: function () {
var cm = grid.jqGrid('getColProp', 'flag'),
selRowId = grid.jqGrid('getGridParam', 'selrow');
cm.editoptions.src = 'http://www.ok-soft-gmbh.com/img/flag_' + selRowId + '.gif';
}
So you will receive the edit form like
for the grid
See the corresponding demo here.
精彩评论