2015-04-09 18 views
13

Potrzebuję dodać klasy do td z GridView. Znalazłem renderTagAttributes(), ale nie mogę znaleźć przykładów, jak z niego korzystać. Czy możesz wyjaśnić mi tę funkcję lub zaoferować mi inną opcję?Jak dodać klasę do tagów <td> w GridView

Moje 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}', 
     ] 
    ], 
]); ?> 

góry dzięki

Odpowiedz

34

Na przykład

[ 
    'attribute' => 'name', 
    'contentOptions' => ['class' => 'text-center'], 
    'headerOptions' => ['class' => 'text-center'] 
], 

contentOptions - dla komórek td, headerOptions - dla komórek th

referencyjny: Yii2 Docs | Column classes in GridView

+0

Dziękuję, Alex – Kevin7

+0

dlaczego nie pracować x_x – Abutouq

+0

Thx do ciebie !!!!! – dimka3210

Powiązane problemy