Yii: Filter with CActiveDataProvider in grid view gives error

I am trying to use filters in cGridview with cActiveDataProvider but it gives following exception

[color="#FF0000"]CActiveDataProvider and its behaviors do not have a method or closure named "getValidators"[/color]

Please check following code

Controller


public function actionAdmin()

	{

        $admin_type=Yii::app()->user->isAdmin;

        if($admin_type==1)

        {

            $admin_batches=WebHelper::getAllAdminBatchesInArray(Yii::app()->user->getId());

            if(!empty($admin_batches))

            {

                $batch_list=implode(",",$admin_batches);

            }

             $batch_criteria="group_id IN ( ".$batch_list." ) and status!=-1";

        }

        else

            $batch_criteria="1 and status!=-1";


        $model=new CActiveDataProvider('Users',array('criteria'=>array(

                    'condition'=>$batch_criteria,

                )));

     

        //$model->unsetAttributes();  // clear any default values

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

			$model->attributes=$_GET['Users'];


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

			'model'=>$model,

		));

	}

View


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

	'id'=>'users-grid',

	'dataProvider'=>$model,

	//'filter'=>$model,

	'columns'=>array(

        array(

			'class'=>'CButtonColumn',

            'htmlOptions'=>array('width'=>'70px'),

            'buttons' => array(

                                'view' => array(

                                    'imageUrl' => Yii::app()->baseUrl . '/themes/gamify/images/view-image.png'

                                ),

                                'update' => array(

                                    'imageUrl' => Yii::app()->baseUrl . '/themes/gamify/images/Edit-icon.png'

                                ),

                                'delete' => array(

                                    'imageUrl' => Yii::app()->baseUrl . '/themes/gamify/images/Delete-icon.png'

                                )

                            )

		),

		//'user_id',


		'first_name',

		'last_name',

		'user_name',

        'group.group_title',

		//'password',

		'email_id',

        array(

            'type'=>'raw',

            'name'=>'Status',

            'value'=>'($data->status==0)?"<a href=\'\' id=\'$data->user_id\' class=\'user_status Active\'>Active</a>":"<a href=\'\' id=\'$data->user_id\' class=\'user_status Inactive\'>Inactive</a>"'

        ),


		


	),

)); ?>

Note:Also if someone can tell me that how can I enable default sorting on column "group.group_title"

Hi Talha Malik, welcome to the forum.

A CActiveDataProvider is not a CActiveRecord. So it doesn’t have ‘attributes’ properties that a CActiveRecord has.

Please read through the following wiki to get a clear concept what CActiveDataProvider is.

http://www.yiiframework.com/wiki/381/cgridview-clistview-and-cactivedataprovider