Danyal Sandeelo
Danyal Sandeelo

Reputation: 12391

Apply class on a table of GridView Yii2

I want to apply class on table generated by GridView::widget() in Yii2.

 <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],
            'mobile_number',
            'email:email',
            'name',
            'national_id',// and so....

How can I apply the CSS on the table GridView::widget()? I want to apply this:

<table class="table tblSec">

Upvotes: 2

Views: 6538

Answers (1)

rob006
rob006

Reputation: 22144

You can use tableOptions property for this:

<?= GridView::widget([
    'dataProvider' => $dataProvider,
    'filterModel' => $searchModel,
    'tableOptions' => ['class' => 'table tblSec'],
    // ...
]) ?>

Upvotes: 14

Related Questions