在JQGrid中设置自定义搜索选项

时间:2014-02-12 09:42:52

标签: jquery search jqgrid

请看一下这张图片。 Search

在下拉列表中是搜索选项的集合。我想要的是将这些选项减少到仅相等而不相等。我不希望其他选项显示出来。我试过这样做 但它不起作用。任何帮助表示赞赏。

navGrid("#pager", {search:true, edit:false,add:false,del:false,searchtext:"Search",refreshtext:"Refresh" },
                  {sopt: ['eq','ne']}      
       );

3 个答案:

答案 0 :(得分:1)

 jQuery("#dataTable").jqGrid('navGrid','#pagingDiv',
            {
                search:true,
                edit:false,
                add:false,
                del:false
            },
            {},
            {},
            {},
            {
                multipleSearch:false, multipleGroup:false, showQuery: false,
                sopt: ['eq', 'ne', 'cn', 'nc', 'bw', 'ew'],
                defaultSearch: 'cn'
                //optDescriptions: {eq:'my eq', gt:'after', le:'on or before'}
            }

            );

答案 1 :(得分:0)

Based on this (link)

navGrid("#pager", 
{
    search:true, 
    edit:false,
    add:false,
    del:false,
    searchtext:"Search",
    refreshtext:"Refresh",
    searchoptions:{
                      sopt: ['eq','ne']
                  }
});

答案 2 :(得分:0)

为jqgrid中的过滤器搜索选项添加此sopt:['eq','ne']条件。

jqgrid中的总可用搜索选项是

sopt:['eq','ne','lt','le','gt','ge','bw','bn','in','ni','ew','en','cn','nc']

替换以下代码:

$("#listCountry").jqGrid('navGrid','#pagerDiv',
{edit:false,add:false,del:false},{},{},{},{sopt:['eq','ne']});

<强>脚本:

$(document).ready(function(){

    //jqGrid
    $("#listCountry").jqGrid({
        url:'<%=request.getContextPath()%>/Admin/getCountriesList',
        datatype: "json",           
        colNames:['Edit','Country Code','Country Name','Active'],
        colModel:[                  
            {name:'countryId',search:false, index:'countryId', width:30,sortable: false, formatter: editLink},                  
            {name:'countryCode',index:'countryCode', width:100},
            {name:'countryName',index:'countryName',width:250}, 
            {name:'isActive',index:'isActive',width:80},
            ],
            rowNum:20,
            rowList:[10,20,30,40,50],
            rownumbers: true,  
            pager: '#pagerDiv', headertitles:true,
            sortname: 'countryName',  
            viewrecords: true,  
            sortorder: "asc",              
    });
    $('#gridContainer div:not(.ui-jqgrid-titlebar)').width("100%");
    $('.ui-jqgrid-bdiv').css('height', window.innerHeight * .65);                   
    $('#load_listCountry').width("130");    
    $("#listCountry").jqGrid('navGrid','#pagerDiv',{edit:false,add:false,del:false},{},{},{},{sopt:['eq','ne']});
    $(".inline").colorbox({inline:true, width:"20%"});
});

function editLink(cellValue, options, rowdata, action) {
    return "<a href='<%=request.getContextPath()%>/Admin/addCountry/"+ rowdata.countryId + "' title='Edit' class='ui-icon ui-icon-pencil' ></a>";
}

<强> HTML

<div id="gridContainer">
    <table id="listCountry"></table>
    <div id="pagerDiv"></div>
</div>