【问题标题】:jqGrid editoption values overriding selectoption valuesjqGrid 编辑选项值覆盖选择选项值
【发布时间】:2015-06-04 19:41:54
【问题描述】:

我的 jqGrid 中有以下列:

{ name: 'Active', 
index: 'Active',
width: '55',
align: 'center', 
formatter: 'select', 
editable: true, 
edittype: "select", 
editoptions: { value: { "1": "Yes", "0": "No" }}, 
stype: 'select', 
searchoptions: { value: { "": "All", "1": "Yes", "0": "No" }} 
},

问题在于 editoption 值覆盖了 searchoption 值(因此“All”没有在搜索工具栏中显示为选项)。

我使用的是 jqGrid 3.5.3。我不允许更新到更高版本。

如果有帮助,这里是整个表的声明:

mygrid = jQuery("#GridView").jqGrid({
url: 'Handler.ashx',
datatype: "json",
colNames: ['ID', 'Active Flag'],
colModel: [
    { name: 'ID', index: 'ID', width: '45', formatter: 'integer' },
    { name: 'Active', index: 'Active', width: '55', align: 'center', formatter: 'select', editable: true, edittype: "select", editoptions: { value: { "1": "Yes", "0": "No" }}, stype: 'select', searchoptions: { value: { "": "All", "1": "Yes", "0": "No" }} },
],
rowNum: 50,
height: '403px',
rowList: [5, 10, 20, 50, 100],
 sortname: 'ID',
pager: jQuery('#PageNavigation'),
sortorder: "asc",
viewrecords: true,
caption: "Tasks",
toolbar: [true, "top"],
editurl: 'Handler.ashx'

我还尝试将 editoptions 和 searchoptions 设置为具有相同的值(All、Yes、No),然后使用 onSelectRow 函数在事后更改 editoptions,就像这样,但它不起作用:

onSelectRow: function (id) {
    jQuery('#streamGridView').setColProp('Flag', { editoptions: { value: { "1": "Yes", "0": "No" } });
}

如何解决它,以便我可以有不同的编辑和选择值?

谢谢!

【问题讨论】:

    标签: jqgrid


    【解决方案1】:

    我只是偶然在我的存档中找到了 jqGrid 3.5.3 的源代码。 jqGrid 的复古版本根本没有从searchoptions.value 获得任何值。

    我建议您在创建过滤器工具栏后插入<option value="">All</option>手动。对应的代码可以是

    $("#gs_Active")
        .prepend("<option value=''>All</option>")
        .val("");
    

    以上代码将"All"选项添加到Active列上方的过滤器工具栏,然后选择它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多