I need to add classes to td of a GridView. I've found renderTagAttributes(), but I can't find examples how to use it. Could you explain me this function or offer me other option?
My gridview:
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'id',
'name',
'price',
'quantity',
'created_at',
[
'class' => 'yii\grid\ActionColumn',
'template' => '{update} {delete}',
]
],
]); ?>
Thanks in advance
For example
[
'attribute' => 'name',
'contentOptions' => ['class' => 'text-center'],
'headerOptions' => ['class' => 'text-center']
],
contentOptions - for td cells, headerOptions - for th cells
Reference: Yii2 Docs | Column classes in GridView
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With