Multiple CGridViews

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?

No, like that the filter will all works together, because use the same input.

You should find a way for differentiate the ‘$_GET[‘Enquiry’]’.

You can create 3 class with different name (CHtml::resolveName use get_class, no way to specify another name) or you can try to use the tabular_input in a gridView, but I have no idea about how to do… )))

Yes this looks like it will be tricky to do. Anyone have any more suggestions?