Hi,
I have faced a little roadblock where i have to display two types of buttons according to the value of field which comes from the database.
Code is as follows :
View Page :
<?php
$widget = $this->widget('zii.widgets.grid.CGridView', array(
'id' => 'notifications-grid',
'cssFile' => Yii::app()->baseUrl . '/css/gridview.css',
'dataProvider' => $model->notificationList(),
'enablePagination' => true,
'ajaxUpdate' => false,
'emptyText' => 'No results found.',
'template' => '{items}',
'pager' => array(
'class' => 'LinkPager',
'cssFile' => false,
'header' => '',
'firstPageLabel' => '',
'prevPageLabel' => '<img class="next-btn">',
'nextPageLabel' => '<img class="previous-btn">',
'lastPageLabel' => '',
),
'columns' => array(
array(
'name' => 'id',
'type' => 'raw',
'htmlOptions' => array('class' => 'width40'),
'headerHtmlOptions'=>array('class' => 'width40'),
'header' => 'S/N',
'value' => '$this->grid->dataProvider->pagination->currentPage * $this->grid->dataProvider->pagination->pageSize + ($row+1)',
),
array(
'name' => 'notificationText',
'type' => 'raw',
'htmlOptions'=> array('class'=>'width400'),
'headerHtmlOptions'=>array('class' => 'width400'),
'header' => 'Notification Text',
'value' => '$data->notificationText',
),
array(
'name' => 'createdDate',
'type' => 'raw',
'htmlOptions'=> array('class'=>'width150'),
'header' => 'Created On',
'value' => '$data->createdDate',
),
array(
'class' => 'CButtonColumn',
'header' => 'Actions',
'htmlOptions' => array('class' => 'width110'),
'headerHtmlOptions'=>array('class' => 'width110'),
'template' => '<a class="file-btn" href="/isml/source/portal/index.php/user/editnotification" title="Click here to copy notification"></a>',
'buttons' => array()
),
),));
?>
The following is where i want to display the buttons :
array(
'class' => 'CButtonColumn',
'header' => 'Actions',
'htmlOptions' => array('class' => 'width110'),
'headerHtmlOptions'=>array('class' => 'width110'),
'template' => '<a class="file-btn" href="/isml/source/portal/index.php/user/editnotification" title="Click here to copy notification"></a>',
'buttons' => array()
)
How can i check like
if($data->status==2){ echo 'Button 1'; }else if($data->status==1){ echo 'button 2'; }else echo 'button 3';}
in the array of CButtonColumn ?