How to set Default value in GridView Yii2 -


i'm new in yii2, , need little bit gridview yii2 gridview yii2 http://i60.tinypic.com/35l91g1.png

i have tried make conditional here :

   <?= gridview::widget([     'dataprovider' => $dataprovider,     'filtermodel' => $searchmodel,     'columns' => [         ['class' => 'yii\grid\serialcolumn'],          /*........other attribute here..........*/          [             'attribute' => 'status_dosen',             'value' => "status_dosen"==1 ? "approved": "status_dosen"==null ? "pending": "rejected",         ],         [             'attribute' => 'status_asrama',             'value' => "status_dosen"==1 ? "approved": "status_dosen"==null ? "pending": "rejected",         ],          ], ]);  ?> 

but got error :

error http://i62.tinypic.com/2vxos1z.png

unknown property – yii\base\unknownpropertyexception getting unknown property: backend\modules\aitk\models\aitkrequest::rejected

anybody me please.. how can set default value conditional value?

for attenttion , , thank you.. :)

use closure that:

gridview::widget([         'dataprovider' => $dataprovider,         'filtermodel' => $searchmodel,         'columns' => [             ['class' => 'yii\grid\serialcolumn'],              /*........other attribute here..........*/              [                 'attribute' => 'status_dosen',                 'value' => function ($data){  return $data->status_dosen==1 ? "approved": ($data->status_dosen==null ? "pending": "rejected"); }             ],      ]); 

see more

edit:

use css. add in html or css file:

   .table-striped>tbody>tr:nth-child(odd)>td, .table-striped>tbody>tr:nth-child(odd)>th {       background-color: red;     }  .table-striped>tbody>tr:nth-child(even)>td, .table-striped>tbody>tr:nth-child(even)>th {       background-color: green;     } 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -