Answer the question
In order to leave comments, you need to log in
How to make search filter and sort in GridView Yii2 with modified field?
The situation is this, in the admin panel there is a list of users. I display it using the GridView widget.
echo GridView::widget([
'id' => 'users-visits-grid',
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
//'options' => ['class' => ''],
'tableOptions' => ['class' => 'table table-bordered'],
//'rowOptions' => ['class' => ''],
'layout' => '<div class="GridViewSummary">{summary}</div><div class="panel panel-default"><div class="table-responsive">{items}</div><div class="table-footer">{pager}</div></div>',
'columns' => [
[
'attribute' => 'user',
'format' => 'html',
'value' => function ($model) {
return UserColumn::widget([
'userId' => $model->id
]);
}
],
'role',
[
'attribute' => 'status',
'format' => 'html',
'value' => function ($model, $index, $widget) {
return ProcessingData::getSelectOptionString($model->status, User::getStatusArray());
},
'filterInputOptions' => ['class'=>'form-control', /*'class'=>'select-multiple'*/],
'filter' => ProcessingData::getSelectOption(User::getStatusArray())
],
...
Answer the question
In order to leave comments, you need to log in
Waking up, maybe I misunderstood. The solution looks like this:
'attribute' => 'username',
'format' => 'html',
'label' => 'Пользователь',
'value' => function ($model) {
return UserColumn::widget([
'userId' => $model->id
]);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question