Red Bottle
Red Bottle

Reputation: 3080

How to change font color of GridView?

I have tried adding a table class and change the color from there but it doesn't work. Here is my widget:

  <?= GridView::widget([
    'dataProvider' => $dataProvider,
    'filterModel' => $searchModel,
    'options' => [
              'class' => 'CustomTableClass',
         ],

    'columns' => [
        'Contract_id',
        'Contract_title',
        'Description',
        'Contract_type',
        'Contract_provider',
        'Effective_date',
        'Expiration_date',
        'Status_id',

    ],
]); ?>

Here's my class:

.CustomClass table thead {
   color: #ffffff;}

Upvotes: 1

Views: 1767

Answers (1)

ScaisEdge
ScaisEdge

Reputation: 133360

You have wrong name. In you css you have CustomClass but in options you have CustomTableClass

 <?= GridView::widget([
    'dataProvider' => $dataProvider,
    'filterModel' => $searchModel,
    'options' => [
              'class' => 'CustomClass',
         ],

    'columns' => [
        'Contract_id',
        'Contract_title',
        'Description',
        'Contract_type',
        'Contract_provider',
        'Effective_date',
        'Expiration_date',
        'Status_id',

    ],
]); ?>

but in your case you are trying to change an header css style and you could use

.CustomHeadClass {
  color: #ffffff;
}

.

 <?= GridView::widget([
    'dataProvider' => $dataProvider,
    'filterModel' => $searchModel,
    'headerRowOptions' => [
              'class' => 'CustomHeadClass ',
         ],

    'columns' => [
        'Contract_id',
        'Contract_title',
        'Description',
        'Contract_type',
        'Contract_provider',
        'Effective_date',
        'Expiration_date',
        'Status_id',

    ],
]); ?>

Upvotes: 1

Related Questions