2017-10-28 16 views
0

私はyii2を初めて使っています..どのようにCSSを列に適用するか、yii2のグリッドビューの列ヘッダー?yii2のグリッドビュー列の特定の列にCSSを適用する方法

あなたが詳細モードであなたのコラムを設定する必要が
<?php 

    $gridColumns = [ 
        ['class' => 'yii\grid\SerialColumn'], 
        ['class' => 'yii\grid\CheckboxColumn'], 

        'name', 
        'company_mail', //change the color of heading 
        'no_employees', 
        'email:email', 
        . 
        . 
        .]; 
      echo GridView::widget([ 
      'dataProvider' => $dataProvider, 
      'filterModel' => $searchModel, 
      'columns' => $gridColumns, 
    ]); 
    ?> 

答えて

0

この方法で特定の列スタイル/ CSSを設定できます。

$columns = [ 
    'onenormalcolumn', 
    'anothercolumn', 
    [ 
     'format'=>"ntext", // or other formatter 
     'attribute' => 'theattributeofmodel', 
     'contentOptions' => ['style' => 'width:50px'], // For TD 
     'headerOptions' => ['class' => 'ur-class'] // For TH 

    ] 
] 
0

<?php 
$columns = [ 
    'onenormalcolumn', 
    'anothercolumn', 
    [ 
     'format'=>"ntext", // or other formatter 
     'attribute' => 'theattributeofmodel', 
     'options'=>[ 'style'=>'your rules here' ] 
    ] 
] 
?> 

あなたが列ヘッダのCSSプロパティを変更したい場合は、propreties例えばheaderOptions列を使用する必要がありますYii2 Gridview column options

+0

私は直接使いたいと思っていません... idまたはクラスを与えたいと思っています...そして、CSSからスタイルを適用してください。 //stackoverflow.com/questions/39241292/how-to-change-color-of-header-for-all-gridview-in-yii2 ....ただし、表の内容には適用されません。見出しにはない – Goli

+0

'style 'を使用してクラス名をvalueとして設定します。 – Prescol

+0

'オプション' => [ 'クラス' => 'YourCustomTableClass'、 ]、 2)CSSファイルで(新しいスタイルルールを追加): .YourCustomTableClass { 色ます。#FF0000。 } ...............列HEADINGの色を変更していません。表の内容/ ROWSの色のみを変更します。 – Goli

0

を参照してください:

'columns' => [ 
    ['class' => 'yii\grid\SerialColumn'], 

    ....... 
    'anothercolumn', 
     [ 
     'format'=>"ntext", // or other formatter 
     'attribute' => 'theattributeofmodel', 
     'headerOptions'=>[ 'style'=>'background-color:#ccf8fe' ] 
     ], 

], 
関連する問題