Search code examples
phpyii2

Yii2 GridView change sort icons


I have installed yii2,I want to change GridView Sort icons and class. How I can do this? I searched in yii2 documentation but nothing found.

Yii2 Grid Code:

<?php echo GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
    ['class' => 'yii\grid\SerialColumn'],

        [ 
            'attribute' => 'createdate',
            'label' => Yii::t('app', 'Created'),                
            'value' => function ($data) { return '4 September 2013'; }, 
        ],

    ...

    ['class' => 'yii\grid\ActionColumn'],
  ],
]);

Solution

  • Change your web/css/site.css as below for ascending order(use desc for descending order). Use your own icon url.

    a.asc:after {
    content: url(link/to/images/img.jpg);
    }
    

    Use the below to add class to your cell

    'contentOptions' => ['class' => 'come-class']