Reduce Ajax Call Of Cgridview Filter

The filter box in CGridView is binded with the change js event, so that after inputing something and the input box lost focus, an AJAX request is triggered.

However, if I want to combine multiple condition, there are some waste AJAX requests for each input field I typed. Only after that, the final Ajax request will give me the result I want.

A good solution is to place a button in the top column(on same line of AJAX filters). When clicked the filters will make a AJAX request.


Unnamed QQ Screenshot20121010125609.jpg

But the event action of gridview filer is hard coded. How can I do this without edit the source code of jquery.yiigridview.js?

You could try with a little hack:


[*]Make sure your button code sets some js var or some DOM element to a specific value

[*]Use CGridView’s beforeAjaxUpdate property < > to return false if that value is not matched.

[*]Set back the value in afterAjaxUpdate


I found a work around to avoid ajax call after an input box lost its focus, just by ading this script.

Now the filter auto-ajax-filter hire only by pressing enter