[ ‘attribute‘ => ‘sex‘, ‘value‘=>function ($model,$key,$index,$column){ return $model->sex==1?‘男‘:‘女‘; }, //在搜索条件(过滤条件)中使用下拉框来搜索 ‘filter‘ => [‘1‘=>‘男‘,‘0‘=>‘女‘], //or ‘filter‘ => Html::activeDropDownList($searchModel, ‘sex‘,[‘1‘=>‘男‘,‘0‘=>‘女‘], [‘prompt‘=>‘全部‘] ) ], [ ‘label‘=>‘产品状态‘, ‘attribute‘ => ‘pro_name‘, ‘value‘ => function ($model) { $state = [ ‘0‘ => ‘未发货‘, ‘1‘ => ‘已发货‘, ‘9‘ => ‘退货,已处理‘, ]; return $state[$model->pro_name]; }, ‘headerOptions‘ => [‘width‘ => ‘120‘] ]
[
‘attribute‘ => ‘title‘,
‘value‘ => function ($model, $key, $index, $column) {
return Html::a($model->title,
[‘article/view‘, ‘id‘ => $key]);
},
‘format‘ => ‘raw‘,
],
[
‘label‘=>‘封面图‘,
‘format‘=>‘raw‘,
‘value‘=>function($m){
return Html::img($m->cover,
[‘class‘ => ‘img-circle‘,
‘width‘ => 30]
);
}
],
[
‘label‘=>‘更新日期‘,
‘format‘ => [‘date‘, ‘php:Y-m-d‘],
‘value‘ => ‘updated_at‘
],
//or
[
//‘attribute‘ => ‘created_at‘,
‘label‘=>‘更新时间‘,
‘value‘=>function($model){
return date(‘Y-m-d H:i:s‘,$model->created_at);
},
‘headerOptions‘ => [‘width‘ => ‘170‘],
],
原文:http://www.cnblogs.com/yangyuqiu/p/6432954.html