我有一个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'
],
],
]); ?>
如何使此列可排序和可搜索?任何想法或建议将不胜感激