query->where['pid'])) { $pid = $menu::find()->select('pid')->where(['id' => $dataProvider->query->where['pid']])->scalar(); }*/ $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;'] ],*/ [ 'label' => '排序', 'value' => 'sort', 'options' => ['width' => '50px;'], ], [ 'header' => '名称', 'attribute' => 'title', 'options' => ['width' => '150px;'], 'contentOptions' => ['style' => 'white-space: nowrap;'], ], [ 'header' => '菜单路径', 'content' => function($model, $key){ $tip = Html::a('
', ['menu/index']) . ': '; if($model['pid'] == 0){ return $tip . Html::a($model['title'], ['index', 'pid' => $model['id']]); } else { $nav = Menu::getParentMenus($key); $nav_title = ''; foreach ($nav as $value) { $nav_title .= Html::a($value['title'], ['index', 'pid'=>$value['id']]).' / '; } $nav_title = trim($nav_title, ' > '); return $tip . $nav_title; } }, 'contentOptions' => ['style' => 'white-space: nowrap;'], ], [ 'label' => '分组', 'options' => ['width' => '80px;'], 'value' => function($model){ return $model['group'] ? $model['group'] : ''; } ], [ 'label' => 'URL', 'value' => 'url', 'options' => ['width' => '150px;'], 'contentOptions' => ['style' => 'white-space: nowrap;'], ], [ 'label' => '是否隐藏', 'options' => ['width' => '80px;'], 'content' => function($model){ return $model['hide'] ? Html::tag('span','隐藏',['style'=>'color:#f00;']) : '正常'; }, 'contentOptions' => ['style' => 'white-space: nowrap;'], ], [ 'class' => 'yii\grid\ActionColumn', 'header' => '操作', 'template' => '{edit} {delete}', 'options' => ['width' => '120px;'], 'buttons' => [ 'edit' => function ($url, $model, $key) { return Html::a('', $url, [ 'title' => Yii::t('app', '更新'), 'class' => 'btn btn-xs blue' ]); }, 'delete' => function ($url, $model, $key) { return Html::a('', $url, [ 'title' => Yii::t('app', '删除'), 'class' => 'btn btn-xs red ajax-get confirm' ]); } ], ], ]; ?>