2017-02-10 72 views
0

我在我的项目中使用ui网格,其中我添加了一个反映网格中该列值的平均值的聚集平均行。现在我已经实现了“导出为PDF”选项,但导出网格时不包括反映平均值的页脚行。我看着http://ui-grid.info/docs/#/api/ui.grid.exporter.api:GridOptions并试图提到有:在角度ui网格如何在导出到pdf时包含页脚行

gridOptions.exporterPdfCustomFormatter = function (docDefinition) { 
    docDefinition.styles.footerStyle = { bold: true, fontSize: 10 }; 
    return docDefinition; 
} 

gridOptions.exporterPdfFooter = { text: 'My footer', style: 'footerStyle' } 

gridOptions.exporterPdfFooter = 'My Footer'; 

gridOptions.exporterPdfFooter = { 
    columns: [ 
    'Left part', 
    { text: 'Right part', alignment: 'right' } 
    ] 
}; 

好像这些选项不工作或我做错了。有什么建议么?

回答

0

以下是我能够弄清楚的一种方法。

创建页脚方法

$scope.getFooterValue = function(i){ 
    return $scope.gridApi.grid.columns[i].getAggregationValue(); 
} 

然后创建一个表页脚的“打印PDF” BTN点击

$scope.$on('print', function(event, filter) { 
$scope.gridOptions.exporterPdfFooter = { 

     table: { 
      widths: [ '*'], 

      body: [ 
         [ 'Totals: '], 

      ]   
     } 
    }; 
$scope.export(); 
} 
+0

当你不使用$范围。$ scope.getFooterValue在gridOptions或当做出口(),对不对?这将如何使用呢?另外如果我是列的数量,如果这是一个动态网格,您可能必须在多列中获取聚合值,那么如何传递函数? – MSIslam