jqgrid列中的Image和Select Formatter [英] Both Image and Select Formatter in jqgrid column

查看:84
本文介绍了jqgrid列中的Image和Select Formatter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将jqgrid(Form editing)与动态colmodel一起使用,其中如果有必要,我必须根据一些值来显示单元格内的图像,对于这些值,同一单元格的编辑类型为select.

I'm using jqgrid(Form editing) with dynamic colmodel in which i have to show a image inside a cell if necessary based on some values for which the same cell has the edit type as select.

因此,在查看时图像应显示在网格中,并且在编辑过程中,单元格应设为select.不确定如何使用formatter.

So, the image should be shown in the grid when in view and during edit the cell should be turned as select. Not sure how to use the formatter.

//代码:

  case 'dropdown':    
                  colname.push({   
                            name: this.Name, index: this.Name, width: 130, edittype: "select", formatter: 'select', editoptions: { value: ':Select;' + this.ValueList.slice(0, -1) }, stype: 'select', searchoptions: { value: ':All;' + this.ValueList.slice(0, -1) }, align: 'left', sortable: true });

                        break;

上面的代码用于在编辑过程中将单元格创建为select格式.现在,我必须在同一单元格内添加图像.

The above code is used for creating the cell as select format during edit. Now i have to add a image inside the same cell.

是否必须添加图像formatter这样?不知道在哪里.

Have to add the image formatter something like this?. Not sure where.

//代码:

formatter: function () {
                return "<img src='http://myserver/path/i.jpg' alt='my image' />";
            }

我试图像在上述代码中那样添加formatter,但是它仅显示图像而不显示列的实际文本,并且在编辑中我无法加载所需的选定文本.

I have tried like adding the formatter as it is in the above mentioned code but its showing only the image and not the actual text of the column and in the edit i couldn't load the desired selected text.

我该如何实现?

推荐答案

我建议您使用 select2 插件,它允许使用图像创建非常舒适的选择(请参见此处)并在内部进行搜索选择选项. 答案(请参见另一个演示了如何使用select2在表单编辑,搜索对话框和过滤器工具栏之内.

I would recommend you to use select2 plugin which allows creating very comfortable selects with images (see here) and searching inside of select options. The answer (see the demo) and the another one demonstrates how to use select2 inside of form editing, searching dialog and the filter toolbar.

这篇关于jqgrid列中的Image和Select Formatter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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