Hello,
Just want to ask if it is possible to implement a condition in CButtonColumn.
eg.
if status = 1(USED)
the button will not appear
and
if status = 0(UNUSED)
the button will not appear
This is the current code:
<?php
$itemFilter = array('0'=>'UNUSED', '1'=>'USED');
$grid = $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'vouchers-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
array(
'name'=>'voucher_no',
'type'=>'raw',
'value'=>'$data->voucher_no',
),
'first_name',
'last_name',
'purchase_date',
'date_used',
'barcode',
array(
'name' => 'status',
'value'=>'$data->status ? \'USED\':\'UNUSED\'',
'filter' => $itemFilter,
),
'updated_by',
array
(
'header'=>'Action',
'class'=>'CButtonColumn',
'template'=>'{used}',
'buttons'=>array
(
'used' => array
(
'imageUrl'=>Yii::app()->request->baseUrl.'/images/use.png',
'options'=>array('title'=>'Click this to update this voucher to used voucher'),
'click'=>'addItem',
'url' => 'Yii::app()->createUrl("vouchers/update", array("id"=>$data->voucher_id))',
),
),
),
),
));
?>