index.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. use yii\grid\GridView;
  3. use yii\helpers\Html;
  4. /* @var $this yii\web\View */
  5. /* @var $dataProvider yii\data\ActiveDataProvider */
  6. /* @var $searchModel rbac\models\searchs\Menu */
  7. $this->title = Yii::t('rbac', 'Menus');
  8. $this->params['breadcrumbs'][] = $this->title;
  9. ?>
  10. <?php $this->beginBlock('content-header') ?>
  11. <?= $this->title . ' ' . Html::a('新菜单', ['create'], ['class' => 'btn btn-primary btn-flat btn-xs']) ?>
  12. <?php $this->endBlock() ?>
  13. <div class="box box-primary">
  14. <div class="box-body">
  15. <?= \backend\widgets\grid\TreeGrid::widget([
  16. 'dataProvider' => $dataProvider,
  17. 'keyColumnName' => 'id',
  18. 'parentColumnName' => 'parent',
  19. 'parentRootValue' => null, //first parentId value
  20. 'pluginOptions' => [
  21. 'initialState' => 'collapse',
  22. ],
  23. 'columns' => [
  24. 'name',
  25. 'route',
  26. [
  27. 'attribute' => 'icon',
  28. 'value' => function($model) {
  29. return Html::icon($model->icon);
  30. },
  31. 'format' => 'raw'
  32. ],
  33. [
  34. 'class' => 'backend\widgets\grid\PositionColumn',
  35. 'attribute' => 'order'
  36. ],
  37. [
  38. 'class' => 'yii\grid\ActionColumn',
  39. 'template' => '{create} {view} {update} {delete}',
  40. 'buttons' => [
  41. 'create' => function($url, $model) {
  42. return Html::a(Html::icon('plus'), ['create', 'id' => $model->id], ['class' => 'btn btn-default btn-xs']);
  43. }
  44. ]
  45. ],
  46. ],
  47. ]);
  48. ?>
  49. </div>
  50. </div>