I am using Yii2 Advanced Template. Below is code for generating Gridview widget on index page.
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'invoice_id',
[
'label'=> 'Customer',
'value' => function ($model) {
return ucfirst($model->customer->customer_name);
},
'enableSorting'=> TRUE,
],
'invoice_type',
'timestamp' => [
'label' => 'Sale / Purchase Date',
'attribute' => 'timestamp',
'format' => ['date', 'php:y-m-d h:i:s A'],
],
'payment_option',
['class' => 'yii\grid\ActionColumn','template'=>'{view} {delete}'],
],
]);
?>
The problem is, despite using 'label' and 'enableSorting' for 'customer_name' when I use 'value' property, the Sort link Disappears. How to enable Sort link. Also attaching snapshot of my view;
After Solving the issue, when I click the sort link, i get below error.