loadComplete event gets fired on each filter operation in jqGrid?
Acco开发者_StackOverflowrding to jqGrid wiki page, "This event is executed immediately after every server request."
In my grid, I've a filter toolbar on top.
$(table_data_obj).jqGrid('filterToolbar', {stringResult:true, searchOnEnter:true, autosearch:true, defaultSearch:'cn'});
and loadComplete function like:
loadComplete: function(data) {
data_processing(data);
}
Whenever, I filter grid data locally (no new server request), data_processing(data) is being called. And I do not want this behavior. How can I make sure that data_processing(data) gets called only with new server requests.
Edit I want to do some data processing, everytime new data is fetched from server. Is there a better place for that ?
You don't posted the jqGrid definition and not describes why you have sometime data from the server and sometime locally. I suppose that you use loadonce:true
option and sometime reset datatype
parameter of jqGrid to the original value 'json' or 'xml' if you need to reload data from the server. If it is your case I would recommend you to test whether the datatype
parameter are 'local' or not. You can use either the if like if ($("#list").jqGrid('getGridParam','datatype') !== 'json') {/* local data */}
or use just $("#list")[0].p.datatype
instead of $("#list").jqGrid('getGridParam','datatype')
. If the data are loaded from the server the datatype
will be 'json' (or 'xml'). After processing of loadComplete
event the datatype
will be changed to the 'local' if you use loadonce:true
option.
use firebug to watch the request to server. check params, u'll get idea which values are being posted. use alerts in events to figure out the specific event throwing server request
精彩评论