Yii Framework Forum: Multiple CGridViews - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Multiple CGridViews Rate Topic: -----

#1 User is offline   GSTAR 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,034
  • Joined: 30-October 09
  • Location:UK

Posted 19 July 2010 - 05:02 AM

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?
0

#2 User is offline   zaccaria 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 2,232
  • Joined: 04-October 09
  • Location:Moscow

Posted 19 July 2010 - 05:25 AM

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... )))
0

#3 User is offline   GSTAR 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,034
  • Joined: 30-October 09
  • Location:UK

Posted 21 July 2010 - 05:14 AM

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

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users