I would like to put 3 CGridView widgets in one view. Each one will be populated by a separate db query. Currently I have the following in my controller:
$criteria=new CDbCriteria(array( 'with'=>array('user', 'topic'), 'together'=>true, 'order'=>'topic.topicId desc, createDate desc', )); $dataProvider=new CActiveDataProvider('Rant', array( 'pagination'=>array( 'pageSize'=>15, ), 'criteria'=>$criteria, )); $this->render('index',array( 'dataProvider'=>$dataProvider, ));
And in my index view:
$this->widget('zii.widgets.grid.CGridView', array( 'dataProvider'=>$dataProvider, //'filter'=>$model, 'columns'=>array( array( 'name' => 'Date', 'value' => 'Rant::formatDate($data->createDate)', ), 'title', ), ));
I’m a bit lost as to how to go about adding an additional two CGridView widgets to my view. Is it possible to pass in multiple dataProviders?
Would it be better to use renderPartial view? If I did use renderPartial would I have to put the CDbCriteria in the view instead of the Controller - the examples I have seen only show it being done that way and it seems like poor separation of display from logic.