0

我正在使用 jqGrid 高级搜索。我不想用空值搜索,所以我为所有字段设置required:true了搜索规则 ( )。searchrules:{required:true}我的问题是我收到“字段是必需的”错误消息,如果我选择是null运算符并单击查找弹出窗口中的查找按钮。

$(document).ready(function() {
    var grid = $("#list"),
        mydata = [
           {id:"1",invdate:"2007-10-01",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"},
           {id:"2",invdate:"2007-10-02",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"},
           {id:"3",invdate:"2007-09-01",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"}
        ];

    grid.jqGrid({
        datatype: "local",
        data: mydata,
        colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'],
        colModel:[
            {name:'id',index:'id', key: true, width:70, sorttype:"int",searchrules:{required:true}},
            {name:'invdate',index:'invdate', width:90, sorttype:"date",searchrules:{required:true}},
            {name:'name',index:'name', width:100,searchrules:{required:true}},
            {name:'amount',index:'amount', width:80, align:"right",sorttype:"float",searchrules:{required:true}},
            {name:'tax',index:'tax', width:80, align:"right",sorttype:"float",searchrules:{required:true}},
            {name:'total',index:'total', width:80,align:"right",sorttype:"float",searchrules:{required:true}},
            {name:'note',index:'note', width:150, sortable:false,searchrules:{required:true}}
        ],
        search:true,
        pager:'#pager',
        jsonReader: {cell:""},
        rowNum: 10,
        rowList: [5, 10, 20, 50],
        sortname: 'id',
        sortorder: 'asc',
        viewrecords: true,
        height: "100%",
        caption: "Multiple search with local data"
    });
    grid.jqGrid('navGrid','#pager',{add:false,edit:false,del:false,search:true,refresh:true},
                {},{},{},{multipleSearch:true, multipleGroup:true, showQuery: true});
});

代码

<table id="list"></table>
<div id="pager"></div>

谢谢

4

1 回答 1

0

在我看来,使用nulloperator 的要求与规则相矛盾searchrules: {required: true}。该规则required: true表示搜索字段的数据不能为空。另一方面,null运营商没有数据。

于 2013-05-08T08:42:01.640 回答