Error with CGridView

Hello friends

I´m Have a problem with CGridView, when I use with a common model, for exemple:




public function actionIndex()

    {

        $dataProvider = new CActiveDataProvider(Distribuidores::model()->status_ativo()->ordem_alfabetica());

        $this->render('index',array('dataProvider'=>$dataProvider));

    }



This works ok.

But I need use CGridView only data of relation, I have this relation in my model Distribuidores:




public function relations()

	{

		return array(

                        'ipsdistribuidor' => array(self::HAS_MANY, 'IpsDistribuidor','id_distribuidor'),

		);

	}



and in model IpsDistribuidor I have this relation:




public function relations()

	{

		return array(

			'id_distribuidor0' => array(self::BELONGS_TO, 'Distribuidores', 'id_distribuidor'),

		);

	}



On my controller DistribuidoresController I have this action:




   public function actionDadosDetalhadoDeals()

    {

        $model = $this->loadModel();

        $this->render('dados_detalhado_deals',array('model'=>$model,'dataProvider'=>$model->ipsdistribuidor)); 

        

    }



this part ‘model’=>$model I use on CDetailView, thats works ok, this part ‘dataProvider’=>$model->ipsdistribuidor I need uso in CGridView,

To test I do this in my view echo "test: " . $model->ipsdistribuidor[0]->id;

Return data, So relation is work.

But when I use on CGridView return this error:

Fatal error: Call to a member function getData() on a non-object in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\yii\framework\zii\widgets\CBaseListView.php on line 105

If I use this form:




public function actionDadosDetalhadoDeals()

    {

        $model = $this->loadModel();

     

        $dataProvider = new CActiveDataProvider(IpsDistribuidor::model()->findbyPk(12));

        $this->render('dados_detalhado_deals',array('model'=>$model,'dataProvider'=>$dataProvider)); 

        

    }



Works but dont use the relation.

How I fix this? I need use a relation

Good Afternoon

I solved my problem using this method:




$dataProvider = new CActiveDataProvider('IpsDistribuidor',array(

            'criteria'=>array(

              'condition'=>'id_distribuidor="'.$model->id.'"',

            ),

            'pagination'=>array(

                'pageSize'=>10,

            )

        ));



But with this method I dont use my relation, I make another filter. There is a way to use relation or this is the unique method?

I Would like to use something, like this:




public function actionDadosDetalhadoDeals()

    {

        $model = $this->loadModel();

        $this->render('dados_detalhado_deals',array('model'=>$model,'dataProvider'=>$model->ipsdistribuidor)); 

        

    }