2016-08-31 9 views
0

の設定:Yii2、DynaGrid、GridViewコントロール:私はDynaGridに列幅を設定しようと列幅

echo DynaGrid::widget([ 
    'columns' => [ 
     [ 
      'attribute' => 'shortcut', 
      'width' => '75px', 
     ], 
     ... 
    ], 
    ... 
]); 

参照してください:http://demos.krajee.com/dynagrid

それは動作しません。

<th style="width:75px;" data-col-seq="0">...</th> 

をしかしCOLGROUPに別の値と同じ列にある:結果のテーブルでは番目の要素が正しく設定されている

<colgroup> 
    <col style="width: 32px;"> 
    ... 

がどのように私はCOLGROUPで幅の値を変更することができますか?

答えて

0

最後に、私の作品1つのエレガントな解決策を、発見しました。 DynaGridテーブルの先頭にある検索フィールドの最小幅は、assets/dynagrid/indexに設定されています。CSS:

.form-control { 
    min-width: 55px; 
} 

非常にシンプル:-)

これは、ユーザーによって報告された問題を、解決します。列が狭すぎると、検索フィールドに入力が表示されませんでした。

0

私は、次のアプローチ(suggestions of Ulises Trujillos Aguirreを参照)試してみました!資産/ dynagrid/index.cssで

重要なの改質剤

'columns' => [ 
    [ 
     'attribute' => 'shortcut', 
     'width' => '75px !important', 
    ], 

CSS

'columns' => [ 
    [ 
     'attribute' => 'shortcut', 
     'width' => '75px !important', 
     'options' => [ 
      'class' => 'col-width-75', 
     ], 
    ], 

を:

.col-width-75 { 
    width: 75px !important; 
} 

jQueryの資産/ dynagrid/index.jsで

<th style="width:75px !important;" data-col-seq="0">...</th> 
... 
<col class="col-width-75" style="width: 32px;"> 

開発ツールで:

出力以下、私が受け取る

$(document).ready(function() { 
    $('.col-width-75').css('width:75px !important'); 
    ... 
}); 

については、:

要素スタイル{ 幅:150px!重要; }

COL用:

element.style { 幅:43px; }

.col-width-150 { width:150px!important; }

ブラウザは見た目がよく、列幅は32ピクセルです。だから、のみ作動溶液は、私は避けたかった間違った1、であることを、次のようになります。

[ 
    'attribute' => 'shortcut', 
    'label' => 'S&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 
    'encodeLabel' => false, 
], 
関連する問題