Answer the question
In order to leave comments, you need to log in
How to disable counter and contentOptions in gridview in yii2?
How can I disable the counter in Yii2? The column name is # and there the numbers go in order.
And why with this code
'columns' => [
[
'class' => 'yii\grid\SerialColumn',
'contentOptions' => function ($model, $key, $index, $column) {
return ['class' => 'myclass' ];
},
],
Answer the question
In order to leave comments, you need to log in
The counter is a SerialColumn, everything is written correctly.
The class for the header can be set via www.yiiframework.com/doc-2.0/yii-grid-column.html#...
GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
[
'class' => 'yii\grid\SerialColumn', // <- колонка со счетчиком
'headerOptions' => ['class' => 'some-class'] // кастомный класс для заголовка
],
'id',
'text:raw',
'created',
'updated',
['class' => 'yii\grid\ActionColumn'],
],
]);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question