jqGrid 编辑选项值覆盖选择选项值

jqGrid editoption values overriding selectoption values

我的 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" }} 
},

问题是编辑选项值覆盖了搜索选项值(所以 "All" 没有作为选项显示在搜索工具栏中)。

我正在使用 jqGrid 3.5.3。我不允许更新到更高版本。

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

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 设置为具有相同的值(全部、是、否),然后使用 onSelectRow 函数在事后更改 editoptions,就像这样,但它没有用:

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

如何修复它以便我可以有不同的编辑和 select 值?

谢谢!

偶然的机会,我在我的存档中找到了 jqGrid 3.5.3 的源代码。复古版本的 jqGrid 根本不会从 searchoptions.value 中获取任何值。

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

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

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