$dataProvider, 'columns' => [ ['class' => 'yii\grid\SerialColumn'], 'id', 'name', 'email:email', 'created_at:datetime', ], ]); ?>
$dataProvider, 'filterModel' => $searchModel, 'columns' => [ ['class' => 'yii\grid\SerialColumn'], 'id', 'name', 'email:email', [ 'attribute' => 'created_at', 'format' => ['datetime', 'php:d/m/Y H:i:s'], 'filter' => DatePicker::widget([ 'model' => $searchModel, 'attribute' => 'created_at', 'language' => 'en', 'dateFormat' => 'yyyy-MM-dd', ]), ], ], ]); ?>
$dataProvider,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
[
'attribute' => 'name',
'label' => 'Full Name',
'value' => function ($model) {
return $model->first_name . ' ' . $model->last_name;
},
],
[
'attribute' => 'status',
'filter' => [
User::STATUS_ACTIVE => 'Active',
User::STATUS_INACTIVE => 'Inactive',
],
'content' => function ($model, $key, $index, $column) {
$class = $model->status == User::STATUS_ACTIVE ? 'success' : 'danger';
return '' . $model->getStatusLabel() . '';
},
],
[
'class' => 'yii\grid\ActionColumn',
'template' => '{view} {update}',
],
],
]); ?>
This example demonstrates some customization options available for the GridView widget. It includes a custom column for the user's full name, custom status labels and styling, and an action column that only displays the view and update buttons.
The GridView widget is a part of the Yii framework's yii\grid package.