【问题标题】:Both Image and Select Formatter in jqgrid columnjqgrid 列中的图像和选择格式化程序
【发布时间】:2014-08-26 09:25:50
【问题描述】:

我正在使用带有动态colmodel 的 jqgrid(表单编辑),如果需要,我必须根据某些值在单元格内显示图像,其中相同单元格的编辑类型为select

因此,在视图和编辑过程中,图像应显示在网格中,单元格应设为select。不知道如何使用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 格式。现在我必须在同一个单元格内添加一个图像。

必须添加图像formatter 像这样吗?不知道在哪里。

//代码:

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

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

我怎样才能做到这一点?

【问题讨论】:

    标签: jquery jqgrid


    【解决方案1】:

    我建议您使用select2 插件,它允许使用图像创建非常舒适的选择(请参阅here)并在选择选项内进行搜索。 The answer(参见the demo)和the another one 演示了如何在表单编辑、搜索对话框和过滤器工具栏中使用select2。

    【讨论】:

      猜你喜欢
      • 2019-06-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-30
      • 2012-06-17
      • 1970-01-01
      相关资源
      最近更新 更多