Just wanted to know if I’m going about this in the correct way. I need to display 3 CGridViews on the same page. Each one has a different criteria. So what I have done is:
Model:
- Created 3 seperate search() functions with their own criteria
View:
- Created 3 seperate cgridviews, with their own ‘id’, ‘dataProvider’ and ‘filter’ properties
Controller:
public function actionAdmin()
{
$model1=new Enquiry('search1');
$model2=new Enquiry('search2');
$model3=new Enquiry('search3');
$model1->unsetAttributes(); // clear any default values
$model2->unsetAttributes(); // clear any default values
$model3->unsetAttributes(); // clear any default values
if(isset($_GET['Enquiry']))
{
$model1->attributes=$_GET['Enquiry'];
$model2->attributes=$_GET['Enquiry'];
$model3->attributes=$_GET['Enquiry'];
}
$this->render('admin', array(
'model1'=>$model1,
'model2'=>$model2,
'model3'=>$model3,
));
}
Is this the correct method?