如何在编辑模式下在 jqgrid 中显示图像 [英] How to show image in jqgrid in edit mode

查看:38
本文介绍了如何在编辑模式下在 jqgrid 中显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

jqGrid 包含下面使用 colmodel 定义的图像列.图像 id 在 json 中从服务器的单元格值中传递.如果不在编辑模式下,网格可以正确显示图像.

内联和表单编辑模式显示错误图像,因为 editoptions src 属性包含固定 id 1

如何在编辑模式下显示来自可编辑行 ID 的图像?如何像格式化函数一样将单元格值传递给editoptions src属性?

name:"图片",编辑类型:图像",编辑选项:{ src:GetImage?id=1"},格式化程序:函数(单元格,选项,行){return "<img src='GetImage?id=" + cell + "'/>"}

解决方案

我可以建议你在开始编辑之前立即更改 editoptionssrc 属性的值.看看 .

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: "GetImage?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.

这篇关于如何在编辑模式下在 jqgrid 中显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆