Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Yii CGridView filter on button click

Tags:

php

yii

cgridview

i have some table in YII that uses CGridView. I want to be able to enter all filtering data and then click on some button and only then send request to server. Right now request is sent every time filter value changes. Is there any native Yii CGridView option to specify that?

like image 439
Justinas Avatar asked Mar 21 '23 19:03

Justinas


1 Answers

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); 
like image 145
Goodnickoff Avatar answered Apr 02 '23 04:04

Goodnickoff