【问题标题】:jqGrid add custom search operator (ops object)jqGrid 添加自定义搜索运算符(ops 对象)
【发布时间】:2013-05-11 10:25:40
【问题描述】:

如何在不直接干预文件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"} ]

此更改可以正常工作,但您可以使用外部文件进行更改吗?

【问题讨论】:

    标签: jquery search jqgrid


    【解决方案1】:

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

    内部结构ops将在jqGrid的下一个版本中改变。所以我建议您在afterRedraw 中即时修改&lt;select&gt; 选项。查看the answerthis onethis one 以获得相应的代码示例。在您的情况下,您可以使用

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

    The demo 使用上面的afterRedraw 并显示

    demo使用localdatatype,所以用操作搜索是不行的,但是postData参数会根据选择的操作设置。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-18
      • 1970-01-01
      • 2019-08-20
      • 2011-06-21
      • 1970-01-01
      相关资源
      最近更新 更多