Yii2 GridView Sort Icons
I have installed yii2, I want to change the icons and the sorting class of the GridView. How can i do this? I have searched in yii2 documentation but found nothing.
Yii2 Summary 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'],
],
]);
+3
source to share
2 answers
try creating your own class extending ActionColumn
class myActionColumn extends ActionColumn {
public function initDefaultButtons()
{
if (!isset($this->buttons['view'])) {
$this->buttons['view'] = function ($url, $model, $key) {
$options = array_merge([
'title' => Yii::t('yii', 'View'),
'aria-label' => Yii::t('yii', 'View'),
'data-pjax' => '0',
], $this->buttonOptions);
return Html::a('<span class="glyphicon glyphicon-eye-open"></span>', $url, $options);
};
}
if (!isset($this->buttons['update'])) {
$this->buttons['update'] = function ($url, $model, $key) {
$options = array_merge([
'title' => Yii::t('yii', 'Update'),
'aria-label' => Yii::t('yii', 'Update'),
'data-pjax' => '0',
], $this->buttonOptions);
return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, $options);
};
}
if (!isset($this->buttons['delete'])) {
$this->buttons['delete'] = function ($url, $model, $key) {
$options = array_merge([
'title' => Yii::t('yii', 'Delete'),
'aria-label' => Yii::t('yii', 'Delete'),
'data-confirm' => Yii::t('yii', 'Are you sure you want to delete this item?'),
'data-method' => 'post',
'data-pjax' => '0',
], $this->buttonOptions);
return Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, $options);
};
}
}
}
and change what you need and use this class instead of ActionColumn class
0
source to share