我是Angular UI-GRID的新手,我需要为PDF导出等导出功能创建外部按钮,我已经阅读了文档,发现我可以使用PDFMake库通过文档创建复杂的头,我没有找到任何例子来解决我的问题。
请查看图像并帮助我。我如何结合这两个功能?
var docDefinition = {
content: [
{
layout: 'lightHorizontalLines', // optional
table: {
// headers are automatically repeated if the table spans over multiple pages
// you can declare how many rows should be treated as headers
headerRows: 1,
widths: ['*', 'auto', 100, '*'],
body: [
['First', 'Second', 'Third', 'The last one'],
['Value 1', 'Value 2', 'Value 3', 'Value 4'],
[{ text: 'Bold value', bold: true }, 'Val 2', 'Val 3', 'Val 4']
]
}
}
]
};
// #region export data
pdfMake.createPdf(docDefinition).open();
// #endregion
// with this I can export pdf with table
var grid = $scope.gridApi.grid;
var rowTypes = uiGridExporterConstants.ALL;
var colTypes = uiGridExporterConstants.ALL;
uiGridExporterService.pdfExport(grid, rowTypes, colTypes);
//With this I can export my grid but without header.
可以使用header函数并在其中添加表格:
header: function() {
return {
table: {
// Add your table data here
},
};
},