Hi, i want to search multiple models in application. The search result displayed in CList view. So how can i use multiple dataprovider in Clist view?
Hi, i want to search multiple models in application. The search result displayed in CList view. So how can i use multiple dataprovider in Clist view?
If you want to get quickly response, don’t let people guess your problem. It’s better provide your code, or screen shots to show the details.
i want to show 2 models data in list view
controller
public function actionData()
{
$dataProvider=new CActiveDataProvider('Address');
$dataProvider2=new CActiveDataProvider('Test');
$this->render('data',array(
'dataProvider'=>$dataProvider,
'dataProvider2' => $dataProvider2,
));
}
data.php
<?php $this->widget('zii.widgets.CListView', array(
'dataProvider'=>$dataProvider,
'itemView'=>'view',
));
?>
<?php $this->widget('zii.widgets.CListView', array(
'dataProvider'=>$dataProvider2,
'itemView'=>'view',
));
?>
in view.php how i print data?
You can use $data. See this wiki, it may help you.
I do not understand the problem, the code you have shown should work. It should show the two dataproviders in two list views?
both are different models. So when we identify the model in view?
In your code, you try to use one view form? if you want to show two list views from different module, it’s better use different view forms. Below is one example to do that.
<?php $this->widget('zii.widgets.CListView', array(
'dataProvider'=>$dataProvider,
'itemView'=>'_view',
));
$this->widget('zii.widgets.CListView', array(
'dataProvider'=>$dataProvider2,
'itemView'=>'../test/_view',
));
?>
Still not sure why you want to show two list views in one page?
Hi I think Johnny gan was right code posting if you want to show the two list view on same page you want to create the different layout otherwise if model relationship are proper so you want to fetch the record in both the table using CDbCriteria join condition.
for e.g…
check this stackoverflow