且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

jqGrid:始终显示选择内容的可编辑列

更新时间:2023-02-09 18:49:13

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

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.