Hey guys, I’m battling CActiveDataProvider and I’m losing it.
I need to display a list of customer with Status "New" and the list should be sorted in descending order of customer_id.
Problem is, no matter what I do with CActiveDataProvider I cant seem to make it work. I either take away the search() and it stops filtering the grid or I add the search() and the grid gets resorted by the search()
Controller
public function actionRegistered()
{
$criteriaPrivate=new CDbCriteria;
$criteriaPrivate->addcondition('status="New"');
$dataProvider = new CActiveDataProvider('Client', array(
'criteria'=>$criteriaPrivate,
'pagination' => array('pageSize' => 30,),
'sort'=>array(
'defaultOrder'=>'customer_id DESC',
),
)
);
$model = new Client('search');
//$model->status='New';
$model->groupsize='';
//$model->customer_id;
//$model ->unsetAttributes();
if(isset($_GET['Client']))
$model->attributes=$_GET['Client'];
$this->render('registered', array(
'dataProvider'=>$dataProvider,
'model'=>$model,
)
);
}
View
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'customer_id',
'dataProvider'=>$dataProvider,
'filter'=>$model,
'enablePagination'=>true,
'columns'=>array(
//'customer_id',
'fname',
'lname',
'email',
'phone',
'groupsize',
'date_created',
array(
'class'=>'CButtonColumn',
'template'=>'{update}',
'updateButtonUrl'=>'Yii::app()->controller->createUrl("/client/waitingupdate",array("id"=>$data["customer_id"]))',
'updateButtonImageUrl'=>'',
),
),
));?>
Any ideas on what can I do?