Cgridview Ajax Filtering/searching Does Not Works

i have a users table on my db and it’s CActiveRecord completely generated by gii

here is my search method inside my model:

	public function search()


		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;













		return new CActiveDataProvider($this, array(




in my view:

$model = new Users('search');

$data = Users::model()->search();

$data->pagination = array(

    'pageSize' => 2,


$this->widget('zii.widgets.grid.CGridView', array(

    'id' => 'my-model-grid',

    'dataProvider' => $data,

    'filter' => $model,

    'enablePagination' => true,

    'enableSorting' =>true,


pagination works fine …

but filtering doesn’t filter anything and showing all table rows for me

$data should be coming from your Users model. The action generally looks something like this:

public function actionIndex()


    $usersFilter = new Users('search');

    $usersFilter->unsetAttributes(); // Sometimes defaults cause problems


    if (isset($_GET['Users']))

        $usersFilter->attributes = $_GET['Users']; // Apply submitted filters

    $dataProvider = $usersFilter->search();

    $this->render('index', array(





In the view, feed $usersFilter and $dataProvider into the widget’s filter and dataProvider attributes.