I have two tables Table A and Table B.
I have the pk of table A ,as fk called member_id in table B.
While girdview display of table B, I want to show the “Member name” in table A, using the “member_id” in table B.
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'transaction-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'id',
'member_id',
'Location',
...
array(
'class'=>'CButtonColumn',
'template'=>'{view}',
),
),
));
You need to setup a relation to that table, and you can use the relation to reference that field like this:
In your transaction model you would place something like:
and for grid you would do like: