我使用pdf make创建了一个表格,我想在我的视图中显示每个单元格(Region,Group等)。
以下是使用Pdf Header导出的js中的表:
exporterPdfHeader: {
margin: [30, 5, 30, 15],
table: {
widths: [ '*', '*', '*' /*, '*'*/ ],
body: [
[ 'Region: ', 'Group: ', 'MC: ' ],
[ 'District #: ', 'Route #: ', 'Week Ending Date: ' ]
]
}
},
以下是我的观点示例
<div class="selection-header well well-sm">
<div class="row">
<div class="col-xs-6 col-md-4">
<label>Region:</label>
<span>{{searchFilter.region.description}}</span>
</div>
<div class="col-xs-6 col-md-4">
<label>Group:</label>
<span>{{searchFilter.group.description}}</span>
</div>
<div class="col-xs-6 col-md-4">
<label>MC:</label>
<span>{{searchFilter.marketCenter.description}}</span>
</div>
<div class="col-xs-6 col-md-4">
<label>District #:</label>
<span>{{searchFilter.district.description}}</span>
</div>
<div class="col-xs-6 col-md-4">
<label>Route #:</label>
<span>{{searchFilter.route.description}}</span>
</div>
<div class="col-xs-6 col-md-4">
<label>Week Ending Date:</label>
<span>{{searchFilter.endWeek.description}}</span>
</div>
</div>
我希望包含Region的单元格调用此参数并使用pdf make导出,我该怎么做?非常感谢任何帮助
答案 0 :(得分:0)
我认为您需要遵循一些基本的angularJS教程来掌握渲染双向数据绑定数据。下面是您希望实现的Angular示例。请查看以下示例,并修改userInfo
以成为您的docDefinition
。您可能需要嵌套ng-repeat
,但这很容易研究。
控制器
var app = angular.module['ExampleApp,[]);
app.controller('ExampleCtrl', function($scope){
$scope.userInfo= [
{name:'Jani',country:'Norway'},
{name:'Hege',country:'Sweden'},
{name:'Kai',country:'Denmark'}
];
})
查看强>
<body ng-app='ExampleCtrl'>
<table>
<tr>
<th>Name</th>
<th>Country</th>
</tr>
<tr ng-repeat="info in userInfo">
<td>{{info.name}}</td>
<td>{{info.country}}</td>
</tr>
</table>
</body>
<强>结果强>
<body ng-app='ExampleCtrl'>
<table>
<tr>
<th>Name</th>
<th>Country</th>
</tr>
<tr>
<td>Jani</td>
<td>Norway</td>
</tr>
<tr>
<td>Hege</td>
<td>Sweden</td>
</tr>
<tr>
<td>Kai</td>
<td>Denmark</td>
</tr>
</table>
</body>
答案 1 :(得分:0)
我首先在gridoptions之外创建了一个范围测试。然后将范围设置为getData函数。
$scope.test = ''
$scope.getData = function(){
...
$scope.test = $scope.searchFilter.region.description;
}
这是在html
中声明的表达式 {{searchFilter.region.description}}</span>
最后,我在广播中设置pdfheader
$scope.$on('net', function(event, filter) {
$scope.gridOptions.exporterPdfHeader = {
margin: [30, 5, 30, 15],
table: {
widths: [ '*', '*', '*' ],
body: [
[ 'Region: '+ $scope.region, 'Group: ', 'MC: '],
[ 'District #: ', 'Route #: ', 'Week Ending Date: ']
]
}
};
$scope.export();
});