Thursday, 18 December 2014

Reset Filter on CGridView in YII

Yii:: Reset Filter on GridView
1. Add this reset button:
<?php echo CHtml::resetButton('Clear!', array('id'=>'form-reset-button')); ?>
2. Add this jquery:
$('#form-reset-button').click(function()
{
   var id='document-grid';
   var inputSelector='#'+id+' .filters input, '+'#'+id+' .filters select';
   $(inputSelector).each( function(i,o) {
        $(o).val('');
   });
   var data=$.param($(inputSelector));
   $.fn.yiiGridView.update(id, {data: data});
   return false;
});

No comments:

Post a Comment