开发者

Timing of gridComplete event with Trirand's jqGrid

I'm not convinced that the gridComplete event runs "after all the data is loaded into the grid and all other processes are complete," as specified in the documentation.

I've got a grid that is loading correctly. In the gidComplete event, I'm triggering some filtering methods (.extend and .setGridParam) to apply a filter as soon as the grid is loaded. However, although my custom function is firing (seen through console), the filter is not being applied. If I use the setTimeout to delay the execution by a second (or so), then the filter is, in fact, applied. So it seems to me that the gridComplete is firing too early.

Incidentally, the filter function (called setGridFilter()) also fires in an onchange event bound to a select menu (where the user can choose from pre-set filter options开发者_开发技巧). This works perfectly. It's just the gridComplete invocation of this function that is failing.

$("#list3").jqGrid({
   url: 'blah.php',
   colNames: ['blah1','blah2','etc.','PresentationTemplateID'],
   colModel: [name: 'blah1', index: 'blah1'],
       [name: 'blah2', index: 'blah2'],
       [name: 'etc.', index: 'etc.'],
       [name: 'PresentationTemplateID', index: 'PresentationTemplateID', hidden:true]
   viewRecords:true,
   loadonce: true,
   pager: '#pager3',
   search:true,
   gridComplete: function(){
       //var t = setTimeout('setGridFilter()',1000);   //this works, for some reason
       setGridFilter();  //this does not
   }
});

function setGridFilter() {
   var postdata = $("#list3").jqGrid('getGridParam','postData');
   var text = $("#ddlGridFilterMenu").val(), f;
   $.extend(postdata,{filters:'',searchField: 'PresentationTemplateID', searchOper: 'eq', searchString: text});
   $("#list3").jqGrid('setGridParam', { search: text.length>0, postData: postdata });
   $("#list3").trigger("reloadGrid",[{page:1}]);
}


Try using loadComplete instead.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜