jqGrid:始终显示选择的可编辑列 [英] jqGrid: Editable column that always shows a select

查看:29
本文介绍了jqGrid:始终显示选择的可编辑列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 jqgrid 中是否有一种方法可以让一个可编辑的列使用如下 colModel 示例中的选择:

Is there a way in jqgrid to have an editable column that uses a select like in this colModel example:

{ 
name: 'Options', 
index: 'Options', 
width: 150, 
align: 'left', 
resizable: false,
editable: true, 
edittype: 'select', 
editoptions: { 
    value: function() { return buildSelect(); } 
},
formatter: 'select'
}

但总是显示选择?

我以前使用复选框进行此操作,但似乎没有使用选择的方法.理想情况下,我希望它在 celledit 模式下工作.有什么想法吗?

I've got this working before with checkboxes, but there doesn't seem to be a way of doing it with selects. Ideally I'd like this to work in celledit mode. Any ideas?

推荐答案

一切皆有可能.我不确定,你想要的是最好的方法.在大多数情况下,我建议使用一些标准方式,这样您的生活会更轻松,尤其是在更改为您使用的新版本控件之后.

All is possible. I am not sure, that what you want is the best way. In the most cases I recommend to use some standard way, then your live will be easier especially after change to a new version of the control which you use.

尽管如此,您可以使用自定义格式化程序(请参阅 http://www.trirand.com/jqgridwiki/doku.php?id=wiki:custom_formatter) 而不是 formatter: 'select' 以显示您喜欢的列的包含方式.例如,

Nevertheless you can use custom formatter (see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:custom_formatter) instead of formatter: 'select' to show the contain of a column how you as prefer. For example,

{ name: 'Options', width: 150, align: 'left', editable: true, edittype: 'select',
  editoptions: { 
    value: function() { return buildSelect(); } 
  },
  formatter: function (cellvalue, options, rowObject, action) {
    if (cellvalue === 'Yes') {
      return '<select><option value="1" selected="selected">Yes</option>' +
                     '<option value="0">No</option></select>';
    } else {
      return '<select><option value="1">Yes</option>' +
                    '<option value="0" selected="selected">No</option></select>';
    }
  }
}

可用于显示带有是"和否"值的 select,而不是默认的一个当前值(是"或否").您还可以为此类 select 元素的 change 句柄绑定一些函数.

can be used to display select with 'Yes' and 'No' values instead of default one current value ('Yes' or 'No'). You can also bind some function for a change handle of such select elements.

这篇关于jqGrid:始终显示选择的可编辑列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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