开发者

How to show image in jqgrid in edit mode

开发者 https://www.devze.com 2023-04-10 08:10 出处:网络
jqGrid contains image column defined using colmodel below. image id is passed in cell value from server in json.

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

How to show image in jqgrid in edit mode

for the grid

How to show image in jqgrid in edit mode

See the corresponding demo here.

0

精彩评论

暂无评论...
验证码 换一张
取 消