2015-07-02 36 views
2

我試圖找出一種方法來修改PDF的頁眉,當我做出口。kartik GridView Yii2 - 如何配置PDF的輸出配置(頁眉,頁腳,標題)

現在標題說的是Yii2 Grid Export(PDF)Grid Export。

這裏是我用來嘗試修改其代碼:

  'exportConfig' => [ 
       GridView::PDF => [ 
        'label' => 'PDF', 
        'filename' => 'Preceptors', 
        'title' => 'Preceptors',       
        'options' => ['title' => 'Preceptor List','author' => 'Me'],       
       ], 
       GridView::CSV => [ 
        'label' => 'CSV', 
        'filename' => 'Preceptors', 
        'options' => ['title' => 'Preceptor List'],            
       ], 
      ], 

      'export' => [ 
       'PDF' => [ 
        'options' => [ 
         'title' => 'Preceptors', 
         'subject' => 'Preceptors', 
         'author' => 'NYCSPrep CIMS', 
         'keywords' => 'NYCSPrep, preceptors, pdf' 
        ] 
       ], 
      ], 

回答

1

就延長這一優良卡爾蒂克的網格(http://demos.krajee.com/grid)以及超越控制的run()和initExport()是這樣的:

namespace common\widgets; 

use Yii; 
use yii\web\JsExpression; 
use yii\helpers\ArrayHelper; 


class GridView extends \kartik\grid\GridView 
{ 
    protected function initExport() { 
     ... copy original and set whatever you like 
    } 

    public function run() { 
     parent::run(); 
     $this->initExport();   
    } 

} 

當然,根據需要設置您的名稱空間。

+0

謝謝合理! – O2U