那么,我会回答我自己的问题只是为了分享。我只是添加了'loadonce',它工作。
这是我的实际JavaScript代码的版本:
$(document).ready(function() {
var filtro = {"groupOp":"AND","rules":[{"field":"Col1","op":"eq","data":""},
{"field":"Col3","op":"eq","data":""}
{"field":"Col4","op":"eq","data":""}]};
$("#lista").jqGrid({
url:'/module/controller/json-action',
datatype: "json",
postData: { filters: JSON.stringify(filtro) },
mtype: 'POST',
colNames:[, 'Col1', 'Col2','Col3','Col4'],
colModel:[
{name:'N°',index:'ID', width:60, align:"center", hidden:true},
{name:'Col1',index:'Col1', width:150, search:true, searchoptions: { sopt: ['eq'] } },
{name:'Col2',index:'Col2', width:250, align:"left", search:false},
{name:'Col3',index:'Col3', width:120, align:"left", search:true, searchoptions: { sopt: ['eq'] }},
{name:'Col4',index:'Col4', width:60, align:"center", search:true, searchoptions: { sopt: ['eq'] }}]
, rowNum:10
, rowList:[10,20,30]
, pager: '#pager'
, sortname: 'ID'
, viewrecords: true
, sortorder: "desc"
, caption:"Listado de ejemplo"
, loadonce: true
, onSelectRow: function(id) {
$("#ID").val(id);
}
, ondblClickRow: function(id) {
$("#edit").submit();
}
});
$("#lista").jqGrid(
'navGrid', '#pager', { edit:false, add:false, del:false },
{},// settings for edit
{},// settings for add
{},// settings for delete
{ multipleSearch:true/*activa la búsqueda avanzada*/,
closeAfterSearch:true, closeAfterReset:true, recreateFilter:true,
/*la función que define la búsqueda*/
onSearch: function() {}//fin onSearch
,
//the search criteria that user selected before pressing find use below code:
onClose:function() {
}//fin onClose
}
);
});//fin document ready
我所做的一切只是为了增加“loadonce:真”。如果我删除“loadonce:true”,网格将不再过滤。