[Yii Framework] Rajib Kumar CGridView, If Condition

This function change value with If Condition

  1. public function statusBarang($i)
  2.     {
  3.         if($i==1)
  4.             return “Belum diproses”;
  5.         else if($i==2)
  6.             return “Sedang diproses”;
  7.         else
  8.             return “Sudah diproses”;
  9.     }
Now use that for final result
  1. $this->widget(‘zii.widgets.grid.CGridView’, array(
  2.     ‘id’=>‘junction-tab-grid’,
  3.     ‘dataProvider’=>$model->search(),
  4.     ‘columns’=>array(
  5.         ‘id’,
  6.         ‘kodeBarang’,
  7.         array(
  8.             ‘name’=>‘Nama Mahasiswa’,
  9.             ‘type’=>‘raw’,
  10.             ‘value’=>‘Barang::model()->statusBarang($data->statusBarang)’,
  11.         ),
  12.         array(
  13.             ‘class’=>‘CButtonColumn’,
  14.         ),
  15.     ),
  16. ));
Rajib Kumar
http://www.rajibkumar.com

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>