vishal shah vishal shah - 2 months ago 45
Ajax Question

How to prevent default ajax callback on filter fields in Yii cgridview

I am using Yii1.1 Cgridview.

I have added filters to cgridview.The problem is that filters have default ajax callback on keypress of input field.

How can I prevent this default ajax callback on filter fields in Yii cgridview and provide search button submit for filters search?

Ish Ish
Answer

Insert this after CGridView widget:

Yii::app()->clientScript->registerScript('gridFilter',"   
    $(function(){
        $(document).off('change.yiiGridView keydown.yiiGridView');
        $('body').on('click','.updateGridButtonSelector', function() {
        $('#grid_id').yiiGridView('update', {
                data: $('#grid_id .filters input').serialize()
            });

           return false;
        });
    });
", CClientScript::POS_READY);