3

I have a gridview widget which shows my user roles like so:

<?= 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'
        ],
    ],
]); ?>

How can I make this column sortable and searchable? Any ideas or suggestions would be greatly appreciated

natral
  • 775
  • 1
  • 12
  • 32

0 Answers0