= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
//重新定义分页样式
'tableOptions' => ['class' => 'table table-hover'],
'columns' => [
[
'class' => 'yii\grid\SerialColumn',
],
'title',
[
'attribute' => 'name',
'label' => '标识',
'headerOptions' => ['class' => 'col-md-1'],
'filter' => Html::activeDropDownList($searchModel, 'name', $nameMap, [
'prompt' => '全部',
'class' => 'form-control'
]
),
'value' => function ($model, $key, $index, $column){
return ExtendConfigNameEnum::getValue($model->name);
}
],
[
'attribute' => 'extend',
'label' => '自动打印',
'format' => 'raw',
'headerOptions' => ['class' => 'col-md-1'],
'filter' => Html::activeDropDownList($searchModel, 'extend', WhetherEnum::getMap(), [
'prompt' => '全部',
'class' => 'form-control'
]
),
'value' => function ($model, $key, $index, $column){
return WhetherEnum::html($model->extend);
}
],
[
'attribute' => 'sort',
'format' => 'raw',
'headerOptions' => ['class' => 'col-md-1'],
'value' => function ($model, $key, $index, $column){
return Html::sort($model->sort);
}
],
[
'label' => '创建时间',
'attribute' => 'created_at',
'filter' => false, //不显示搜索框
'format' => ['date', 'php:Y-m-d H:i:s'],
],
[
'header' => "操作",
'class' => 'yii\grid\ActionColumn',
'template' => '{edit} {status} {delete}',
'buttons' => [
'edit' => function ($url, $model, $key) {
return Html::edit(['edit', 'id' => $model->id, 'name' => $model->name]);
},
'status' => function ($url, $model, $key) {
return Html::status($model->status);
},
'delete' => function ($url, $model, $key) {
return Html::delete(['destroy', 'id' => $model->id]);
},
],
],
],
]); ?>