<?php Pjax::begin(['options'=>['id'=>'pjax-container']]); ?>
<?php echo GridView::widget([
'dataProvider'=>$dataProvider,
'filterModel'=>$searchModel,
'options'=>['class'=>'grid-view table-scrollable'],
'tableOptions'=>['class'=>'table table-striped table-bordered table-hover table-checkable order-column dataTable no-footer'],
'layout'=>'{items}<div class=""><div class="col-md-5 col-sm-5">{summary}</div><div class="col-md-7 col-sm-7"><div class="dataTables_paginate paging_bootstrap_full_number" style="text-align:right;">{pager}</div></div></div>',
'summaryOptions'=>['class'=>'pagination'],
'pager'=>[
'options' => ['class'=>'pagination','style'=>'visibility: visible;'],
'nextPageLabel' => '下一页',
'prevPageLabel' => '上一页',
'firstPageLabel' => '第一页',
'lastPageLabel' => '最后页'
],
'columns'=>[
'id',
'category_id',
'name',
'title',
'cover',
[
'class'=>'yii\grid\ActionColumn'
]
]
])?>
<?php Pjax::end();?>
$columns = [
[
'class' => \common\core\CheckboxColumn::className(),
'name' => 'id',
'options' => ['width' => '20px;'],
'checkboxOptions' => function ($model, $key, $index, $column) {
return ['value' => $key,'label'=>'','labelOptions'=>['class' =>'mt-checkbox mt-checkbox-outline','style'=>'padding-left:19px;']];
}
],
[
'header' => 'ID',
'attribute' => 'id',
'options' => ['width' => '50px;']
],
[
'header' => '标识',
'options' => ['width' => '150px;'],
'attribute' => 'name'
],
[
'header' => '名称',
'attribute' => 'title'
],
[
'header' => '上级分类',
'content' => function($model){
$str = '';
$paths = Category::getParents($model['category_id']);
foreach ($paths as $value) {
$str .= $value['title'] .' > ';
}
$str = rtrim($str, ' > ');
return $str;
}
],
[
'label' => '排序',
'value' => 'sort',
'options' => ['width' => '50px;'],
],
[
'label' => '状态',
'options' => ['width' => '50px;'],
'content' => function($model){
return '正常';
}
],
[
'class' => 'yii\grid\ActionColumn',
'header' => '操作',
'template' => '{edit} {delete}',
'options' => ['width' => '200px;'],
'buttons' => [
'edit' => function ($url, $model, $key) {
return Html::a('', $url, [
'title' => Yii::t('app', '编辑'),
'class' => 'btn btn-xs purple'
]);
},
'delete' => function ($url, $model, $key) {
return Html::a('', $url, [
'title' => Yii::t('app', '删除'),
'class' => 'btn btn-xs red ajax-get confirm'
]);
},
],
],
];
文章
总共 0 条评论