问题描述
jqGrid包含使用下面的colmodel定义的图像列.图像ID在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.
内联和表单编辑模式显示错误的图像,因为editoptions src属性包含固定ID 1
Inline and form edit mode show wrong image since editoptions src property contains fixed id 1
如何在编辑模式下显示来自可编辑行ID的图像?如何像格式化程序函数中那样将单元格值传递给editoptions src属性?
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: "GetImage?id=1"},
formatter:function(cell,options,row) {
return "<img src='GetImage?id=" + cell + "'/>"
}
推荐答案
我建议您在开始编辑之前立即更改editoptions
的src
属性的值.查看以获取详细信息.如果进行表单编辑,则可以使用 beforeInitData 来修改src
:
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
对于网格
在此处中查看相应的演示.
这篇关于如何在编辑模式下在jqgrid中显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!