請看一下這張圖片。 在JQGrid中設置自定義搜索選項
在下拉列表中是搜索選項的集合。我想要的是將這些選項修剪爲僅相等而不相等。我不希望顯示其他選項。我試圖做 但它不起作用。任何幫助讚賞。
navGrid("#pager", {search:true, edit:false,add:false,del:false,searchtext:"Search",refreshtext:"Refresh" },
{sopt: ['eq','ne']}
);
請看一下這張圖片。 在JQGrid中設置自定義搜索選項
在下拉列表中是搜索選項的集合。我想要的是將這些選項修剪爲僅相等而不相等。我不希望顯示其他選項。我試圖做 但它不起作用。任何幫助讚賞。
navGrid("#pager", {search:true, edit:false,add:false,del:false,searchtext:"Search",refreshtext:"Refresh" },
{sopt: ['eq','ne']}
);
navGrid("#pager",
{
search:true,
edit:false,
add:false,
del:false,
searchtext:"Search",
refreshtext:"Refresh",
searchoptions:{
sopt: ['eq','ne']
}
});
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'}
}
);
添加此sopt:['eq','ne']
條件在jqGrid的過濾搜索選項。在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>";
}
HT ML
<div id="gridContainer">
<table id="listCountry"></table>
<div id="pagerDiv"></div>
</div>
此代碼和我已經嘗試的唯一區別是使用searchoptions,它添加後,它不能實現我想要的.. –