In this example you can see Name attribute using as custom column.
Yii2 gridview custom column
GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'id',
'username',
'created_at',
[
'label' => 'Name',
'value' => function ($model) {
return $model->user->first_name;
}
],
['class' => 'yii\grid\ActionColumn'],
],
]);
No comments:
Post a Comment