1

如何在不直接干预文件的情况下添加搜索运算符jquery.jqGrid.src.js

例子:

ops: [
    {"name": "eq", "description": "equal", "operator": "="},
    {"name": "ne", "description": "not equal", "operator": "<>"},
    {"name": "lt", "description": "less", "operator": "<"},
    {"name": "the", "description": "less or equal", "operator": "<="},
    {"name": "gt", "description": "greater", "operator": ">"},
    {"name": "ge", "description": "greater or equal", "operator": "> ="},
    {"name": "bw", "description": "begins with", "operator": "LIKE"},
    {"name": "bn", "description": "does not begin with", "operator": "NOT LIKE"},
    {"name": "in", "description": "in", "operator": "IN"},
    {"name": "ni", "description": "not in", "operator": "NOT IN"},
    {"name": "ew", "description": "ends with", "operator": "LIKE"},
    {"name": "en", "description": "does not end with", "operator": "NOT LIKE"},
    {"name": "cn", "description": "contains", "operator": "LIKE"},
    {"name": "nc", "description": "Does not contain", "operator": "NOT LIKE"},
    {"name": "noo", "description": "is null", "operator": "IS NULL"},
    {"name": "nn", "description": "is not null", "operator": "IS NOT NULL"},
    {"name": "xx", "description": "xxx", "operator": "CUSTOM"} ]

此更改可以正常工作,但是您可以使用外部文件来完成吗?

4

1 回答 1

1

首先你应该明白,添加自定义搜索运算符并不是遵循运算符的实现。我想你有搜索的服务器端实现。在扩展搜索操作的情况下,大多是简单的。

内部结构ops将在 jqGrid 的下一个版本中改变。所以我建议你<select>afterRedraw. 看答案这个这个对应的代码示例。在您的情况下,您可以使用

afterRedraw: function () {
    $(this).find("table.group td.operators>select.selectopts")
        .append("<option value='xx'>xxx</option>");
}

该演示使用上述内容afterRedraw并显示

在此处输入图像描述

该演示使用local datatype,因此使用操作进行搜索不是原因,但postData参数将设置为与所选操作相对应。

于 2013-05-11T11:22:01.677 回答