<?php

use yii\helpers\Html;

/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '分类';
$this->params['breadcrumbs'][] = $this->title;
?>
<?php $this->beginBlock('content-header') ?>
<?= $this->title . ' ' . Html::a('新建分类', ['create'], ['class' => 'btn btn-success']) ?>
<?php $this->endBlock() ?>

<div class="box box-success">
    <div class="box-body">
        <?= \backend\widgets\grid\TreeGrid::widget([
            'dataProvider' => $dataProvider,
            'keyColumnName' => 'id',
            'parentColumnName' => 'pid',
            'parentRootValue' => 0, //first parentId value
            'pluginOptions' => [
                'initialState' => 'collapse',
            ],
            'columns' => [
                'title',

                [
                    'attribute' => 'icon',
                    'format' => ['image', ['style' => 'height: 40px; width: 40px;border-radius: 50%;border: none;']],
                    'contentOptions' => ['class' => 'media-content']
                ],
//                [
//                    'attribute' => 'cover',
//                    'format' => ['image', ['style' => 'height: 60px; width: 60px;']],
//                    'contentOptions' => ['class' => 'media-content']
//                ],
                [
                    'class' => 'backend\widgets\grid\PositionColumn',
                    'attribute' => 'sort'
                ],
//                [
//                    'class' => 'backend\widgets\grid\SwitcherColumn',
//                    'attribute' => 'is_hot'
//                ],
                [
                    'class' => 'backend\widgets\grid\SwitcherColumn',
                    'attribute' => 'status'
                ],
                [
                    'class' => 'common\helpers\DiyActionColumn',
                    'template' => '{update} {delete}',
                ]
//                [
//                    'class' => 'common\helpers\DiyActionColumn',
//                    'template' => '{create} {update} {delete}',
//                    'buttons' => [
//                        'create' => function($url, $model, $key) {
//                            return Html::a('添加子分类', ['create', 'id' => $model->id], ['class' => 'btn btn-xs btn-success', 'data-toggle' => 'tooltip', 'title' => '添加子分类']);
//                        }
//                    ]
//                ],
            ],
        ]); ?>
    </div>
</div>