Show Multiple Relational Model Attributes In A Cgridview

Hi guys,

I have come up with a small problem while trying to display multiple model attributes (relational) in a CGridView. As a start, I would like to show in a CGridView, data from 2 models. I will show the code below.

This is my CGridView scetion of the Claim (model) admin view


<?php $this->widget('zii.widgets.grid.CGridView', array(

	'id'=>'claim-grid',

	'dataProvider'=>$model->search(),

	'filter'=>$model,

	'columns'=>array(

		'empid',

		'cdescription',

		'camount',

		'cdate',

		array(

			'class'=>'CButtonColumn',

		),

	),

)); ?>

This is my Claim (model) relations section


public function relations()

	{

		// NOTE: you may need to adjust the relation name and the related

		// class name for the relations automatically generated below.

		return array(

			'emp' => array(self::BELONGS_TO, 'Staff', 'empid'),

		);

	}



I want to show name of the employee for the empid in CGridView.

I think this must be very easy task with yii AR instances but I couldn’t get it done yet…

A quick reply is very much appreciated.

Thanks.

Sandun