?> </div> <?php echo NestedTreeGrid::widget(['dataProvider' => $dataProvider, 'initialNode' => $initial, 'tableOptions' => ['class' => 'table table-condensed'], 'rowOptions' => function ($model, $key, $index, $grid) { return !$model->active ? ['class' => 'warning'] : []; }, 'columns' => [['attribute' => 'title', 'format' => 'html', 'value' => function ($model, $key, $index, $column) { $result = Html::encode($model->title); if ($model instanceof GalleryCollection) { $result .= ' ' . Html::tag('span', $model->imageCount, ['class' => 'badge']); } return $result; }], ['class' => 'yii\\grid\\ActionColumn', 'options' => ['style' => 'width: 75px;'], 'template' => '{update} {delete} {create}', 'buttons' => ['create' => function ($url, $model, $key) { if (!$model instanceof GallerySection) { return ''; } $title = Yii::t('gallery', 'Create gallery'); return Html::a('<span class="glyphicon glyphicon-plus"></span>', $url, ['title' => $title, 'aria-label' => $title, 'data-pjax' => 0]); }], 'urlCreator' => function ($action, $model, $key, $index) { if ($action == 'create') { return ['collection/create', 'id' => $model->id]; } if ($action == 'delete') { return ['delete', 'id' => $model->id]; } $route = $action; if ($model instanceof GalleryCollection) { $route = 'collection/' . $route; } return [$route, 'id' => $model->id]; }]]]);
<?php use yii\helpers\Html; use dkhlystov\widgets\NestedTreeGrid; use menu\common\models\Menu; $title = Yii::t('menu', 'Main menu'); $this->title = $title . ' | ' . Yii::$app->name; $this->params['breadcrumbs'] = [$title]; ?> <h1><?php echo Html::encode($title); ?> </h1> <div class="btn-toolbar" role="toolbar"> <?php echo Html::a(Yii::t('menu', 'Create'), ['create'], ['class' => 'btn btn-primary']); ?> </div> <?php echo NestedTreeGrid::widget(['dataProvider' => $dataProvider, 'initialNode' => $initial, 'moveAction' => ['move'], 'tableOptions' => ['class' => 'table table-condensed'], 'rowOptions' => function ($model, $key, $index, $grid) { return !$model->active ? ['class' => 'warning'] : []; }, 'columns' => ['name', ['class' => 'yii\\grid\\ActionColumn', 'options' => ['style' => 'width: 75px;'], 'template' => '{update} {delete} {create}', 'buttons' => ['create' => function ($url, $model, $key) { if ($model->type != Menu::TYPE_SECTION) { return ''; } $title = Yii::t('menu', 'Create'); return Html::a('<span class="glyphicon glyphicon-plus"></span>', $url, ['title' => $title, 'aria-label' => $title, 'data-pjax' => 0]); }]]]]);