2017-07-16 57 views
1

我正在用pdf打印gridview。 gridview很好。但細胞沒有正確填充。我想如果我可以減少一點字體,那麼這個單元格會被正確填充。我減少了寬度。但細胞正在變形。的GridView的在yii2中指定Gridview的字體大小

碼 -

<?= GridView::widget([ 
     'dataProvider' => $dataProvider1, 
     //'filterModel' => $searchModel, 
     'layout'=>"{items}", 
     'columns' => [ 
      ['class' => 'yii\grid\SerialColumn'], 
      'hsncode', 
      [ 
       'label' => 'Productname', 
       'attribute' =>'productname', 
       'headerOptions' => ['style' => 'width:20%'], 
       //'contentOptions' => ['class' => 'col-lg-1'], 
       //'format'=>['decimal',2] 
      ], 
      'batchno', 
      //'expdate', 
      [ 
       'attribute'=>'expdate', 
       'format'=>['DateTime','php:m-y'], 
       'headerOptions' => ['style' => 'width:6%'], 
      ], 
      'mrp', 
      'rate', 

      'qty', 
      'free',   
      'discount', 
      [ 
       'label' => 'Value', 
       'attribute' =>'value', 
       //'contentOptions' => ['class' => 'col-lg-1'], 
       'format'=>['decimal',2] 
      ], 
      [ 
       'label' => 'GST%', 
       'attribute' =>'gstpercent', 
       //'headerOptions' => ['style' => 'width:6%'], 
       //'contentOptions' => ['class' => 'col-lg-1'], 
       'format'=>['decimal',0] 
      ], 


      [ 
       'label' => 'Total', 
       'attribute' =>'totalamount', 
       'headerOptions' => ['style' => 'width:9%'], 
       //'contentOptions' => ['class' => 'col-lg-1'], 
       'format'=>['decimal',2] 
      ], 
     ], 
     ]); ?> 

GridView的樣子 - enter image description here

請讓我知道如何指定GridView中的字體。

回答

1

你可以使用選項網格容器

<?= GridView::widget([ 
     'dataProvider' => $dataProvider1, 
     //'filterModel' => $searchModel, 
     'layout'=>"{items}", 
     'options' => ['style' => 'font-size:12px;'] 
     'columns' => [ 

,或者直接在列

<?= GridView::widget([ 
     'dataProvider' => $dataProvider1, 
     //'filterModel' => $searchModel, 
     'layout'=>"{items}", 
     'options' => ['style' => 'font-size:12px;'] 
     'columns' => [ 
      [ 
       'label' => 'your_label', 
       'attribute' =>'your_attribute', 
       'contentOptions' => ['style' => 'font-size:12px;'] 
      ] 
+0

做工精細。非常感謝。 – Tanmay

相關問題