在yii2中的可搜索/可排序gridview列中显示用户角色(rbac)

时间:2017-07-24 20:03:21

标签: php gridview yii2-rbac

我有一个gridview小部件,它显示我的用户角色:

<?= GridView::widget([
    'dataProvider' => $dataProvider,
    'filterModel' => $searchModel,
    'columns' => [
        ...
        [
            'header' => 'roles',
            'content' => function ($model, $key, $index, $column){
                $auth = Yii::$app->authManager;
                $roles = $auth->getRolesByUser($model->id);
                $string = ' ';
                foreach ($roles as $role) {
                    $string .= $role->name . " ";
                }
                return $string;
            }
        ],
        ...
        [
            'class' => 'yii\grid\ActionColumn'
        ],
    ],
]); ?>

如何使此列可排序和可搜索?任何想法或建议将不胜感激

0 个答案:

没有答案