Hi everyone
I have my cgridview code:
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'timetable-entries-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'id',
'batch_id',
'weekday_id',
'class_timing_id',
'subject_id',
'employee_id',
array(
'class'=>'CButtonColumn',
),
),
)); ?>
I need to customize so as to display the subject name from another table and also display employee name form another table.
Someone to help
Hi Vincent Bii,
I hope this code will help you ->
$this->widget('zii.widgets.grid.CGridView', array(
'id' => 'timetable-entries-grid',
'dataProvider' => $model->search(),
'filter' => $model,
'columns' => array(
'id',
'batch_id',
'weekday_id',
'class_timing_id',
// 'subject_id',
array(
'name' => 'subject_id',
'header' => 'Subject Name',
'value' => function($data, $row) {
$subjectObj = SubjectModel::model()->findByPk($data['subject_id']); //Your Subject Model and match with the primary key
return $subjectObj->subject_name; //Use your subject name field of subject model
},
'type' => 'raw',
'htmlOptions' => array('style' => 'width: 24%'),
),
'employee_id',
array(
'class' => 'CButtonColumn',
),
),
));
Please make use the above code for further customisations.
But this forum is under yii2 - general discussion. Please try to ask in yii 1.1 discussion forum.
Cheers! Happy Coding
Thanks a lot. I appreciate your support
softark
(Softark)
4
[color="#006400"]/* Moved from "2.0" to "1.1" */[/color]