为 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>