I have exported a table using pdfmake within angularjs to a pdf and would like it so when I select 'ALL' routes on the main page, for it to export multiple tables associated with all the Routes within the filter.
Right now it works only when I select a single route it exports that table for that specific route. When I select 'ALL' for a route, it will just show the first table associated with a single route.
$scope.$on('print', function(event, filter) {
var docDefinition = {
info: {
title: 'LCP'
},
content: [
{
margin: [-30,0,-30,-30],
fontSize: 6,
table: {
headerRows: 1,
dontBreakRows: true,
body: [
//header row
[ {text: 'Route/RSR',alignment: 'center', color: 'red'}, {text: 'Weekly L&R Guideline',alignment: 'center', color: 'red'}, '', {text: 'Mon',alignment: 'center', color: 'red'}, {text: 'Tue',alignment: 'center', color: 'red'}, {text: 'Wed',alignment: 'center', color: 'red'}, {text: 'Thu',alignment: 'center', color: 'red'}, {text: 'Fri',alignment: 'center', color: 'red'}, {text: 'Total',alignment: 'center', color: 'red'}, {text: 'Weekly Attain.',alignment: 'center', color: 'red'}, {text: 'RTE AWRV',alignment: 'center', color: 'red'}],
[ '' + $scope.routeRSR, {text: $filter('percentFilter')($scope.weeklyLRGuidelinePercent)}, '% of L&R by Day', {text: $filter('percentFilter')($scope.LRbyDayMon), style: 'tableData'}, {text: $filter('percentFilter')($scope.LRbyDayTues), style: 'tableData'}, {text: $filter('percentFilter')($scope.LRbyDayWed), style: 'tableData'}, {text: $filter('percentFilter')($scope.LRbyDayThurs), style: 'tableData'}, {text: $filter('percentFilter')($scope.LRbyDayFri), style: 'tableData'}, {text: $filter('percentFilter')($scope.LRbyDayTotal), style: 'tableData'}, '', {text: $filter('currencyFilter')($scope.LRbyDayRTEAWRV), style: 'tableData'}],
[ '' + $scope.parmName, ''+ $filter('currencyFilter')($scope.weeklyLRGuidelineCurrency), 'Daily Guideline', {text: $filter('currencyFilter')($scope.dailyGuidelineMon), style: 'tableData'}, {text: $filter('currencyFilter')($scope.dailyGuidelineTues), style: 'tableData'}, {text: $filter('currencyFilter')($scope.dailyGuidelineWed), style: 'tableData'}, {text: $filter('currencyFilter')($scope.dailyGuidelineThurs), style: 'tableData'}, {text: $filter('currencyFilter')($scope.dailyGuidelineFri), style: 'tableData'}, {text: $filter('currencyFilter')($scope.dailyGuidelineTotal), style: 'tableData'}, {text: $filter('percentFilter')($scope.dailyGuidelineWeeklyAttain), style: 'tableData'}, ''],
[ '', '', 'Net Pre Bill L&R $', {text: $filter('currencyFilter')($scope.netPreBillMon), style: 'tableData'}, {text: $filter('currencyFilter')($scope.netPreBillTues), style: 'tableData'}, {text: $filter('currencyFilter')($scope.netPreBillWed), style: 'tableData'}, {text: $filter('currencyFilter')($scope.netPreBillThurs), style: 'tableData'}, {text: $filter('currencyFilter')($scope.netPreBillFri), style: 'tableData'}, {text: $filter('currencyFilter')($scope.netPreBillTotal), style: 'tableData'}, '', ''],
[ '', '', '-EasyCare Pre Bill $', {text: $filter('currencyFilter')($scope.easyCarePreBillMon), style: 'tableData'}, {text: $filter('currencyFilter')($scope.easyCarePreBillTues), style: 'tableData'}, {text: $filter('currencyFilter')($scope.easyCarePreBillWed), style: 'tableData'}, {text: $filter('currencyFilter')($scope.easyCarePreBillThurs), style: 'tableData'}, {text: $filter('currencyFilter')($scope.easyCarePreBillFri), style: 'tableData'}, {text: $filter('currencyFilter')($scope.easyCarePreBillTotal), style: 'tableData'}, '', ''],
[ '', '', '-Non-EasyCare Pre Bill L&R $', {text: $filter('currencyFilter')($scope.nonEasyCarePreBillMon), style: 'tableData'}, {text: $filter('currencyFilter')($scope.nonEasyCarePreBillTues), style: 'tableData'}, {text: $filter('currencyFilter')($scope.nonEasyCarePreBillWed), style: 'tableData'}, {text: $filter('currencyFilter')($scope.nonEasyCarePreBillThurs), style: 'tableData'}, {text: $filter('currencyFilter')($scope.nonEasyCarePreBillFri), style: 'tableData'}, {text: $filter('currencyFilter')($scope.nonEasyCarePreBillTotal), style: 'tableData'}, '', ''],
[ '', '', 'Billed on the Spot', {text: $filter('currencyFilter')($scope.billedOnSpotMon), style: 'tableData'}, {text: $filter('currencyFilter')($scope.billedOnSpotTues), style: 'tableData'}, {text: $filter('currencyFilter')($scope.billedOnSpotWed), style: 'tableData'}, {text: $filter('currencyFilter')($scope.billedOnSpotThurs), style: 'tableData'}, {text: $filter('currencyFilter')($scope.billedOnSpotFri), style: 'tableData'}, {text: $filter('currencyFilter')($scope.billedOnSpotTotal), style: 'tableData'}, '', ''],
[ '', '', 'Net L&R Adjustments', {text: $filter('currencyFilter')($scope.netLRAdjustmentsMon), style: 'tableData'}, {text: $filter('currencyFilter')($scope.netLRAdjustmentsTues), style: 'tableData'}, {text: $filter('currencyFilter')($scope.netLRAdjustmentsWed), style: 'tableData'}, {text: $filter('currencyFilter')($scope.netLRAdjustmentsThurs), style: 'tableData'}, {text: $filter('currencyFilter')($scope.netLRAdjustmentsFri), style: 'tableData'}, {text: $filter('currencyFilter')($scope.netLRAdjustmentsTotal), style: 'tableData'}, '', ''],
[ '', '', '-EasyCare Adjustment $', {text: $filter('currencyFilter')($scope.easyCareAdjustmentsMon), style: 'tableData'}, {text: $filter('currencyFilter')($scope.easyCareAdjustmentsTues), style: 'tableData'}, {text: $filter('currencyFilter')($scope.easyCareAdjustmentsWed), style: 'tableData'}, {text: $filter('currencyFilter')($scope.easyCareAdjustmentsThurs), style: 'tableData'}, {text: $filter('currencyFilter')($scope.easyCareAdjustmentsFri), style: 'tableData'}, {text: $filter('currencyFilter')($scope.easyCareAdjustmentsTotal), style: 'tableData'}, '', ''],
[ '', '', '-Non-EasyCare L&R Adjustments', {text: $filter('currencyFilter')($scope.nonEasyCareLRAdjustmentsMon), style: 'tableData'}, {text: $filter('currencyFilter')($scope.nonEasyCareLRAdjustmentsTues), style: 'tableData'}, {text: $filter('currencyFilter')($scope.nonEasyCareLRAdjustmentsWed), style: 'tableData'}, {text: $filter('currencyFilter')($scope.nonEasyCareLRAdjustmentsThurs), style: 'tableData'}, {text: $filter('currencyFilter')($scope.nonEasyCareLRAdjustmentsFri), style: 'tableData'}, {text: $filter('currencyFilter')($scope.nonEasyCareLRAdjustmentsTotal), style: 'tableData'}, '', ''],
[ '', '', 'Daily Actual', {text: $filter('currencyFilter')($scope.dailyActualMon), style: 'tableData'}, {text: $filter('currencyFilter')($scope.dailyActualTues), style: 'tableData'}, {text: $filter('currencyFilter')($scope.dailyActualWed), style: 'tableData'}, {text: $filter('currencyFilter')($scope.dailyActualThurs), style: 'tableData'}, {text: $filter('currencyFilter')($scope.dailyActualFri), style: 'tableData'}, {text: $filter('currencyFilter')($scope.dailyActualTotal), style: 'tableData'}, {text: $filter('percentFilter')($scope.dailyActualWeeklyAttain), style: 'tableData'}, ''],
[ '', '', 'Actual Pieces Issued', {text: $filter('currencyFilter')($scope.actualPiecesMon), style: 'tableData'}, {text: $filter('currencyFilter')($scope.actualPiecesTues), style: 'tableData'}, {text: $filter('currencyFilter')($scope.actualPiecesWed), style: 'tableData'}, {text: $filter('currencyFilter')($scope.actualPiecesThurs), style: 'tableData'}, {text: $filter('currencyFilter')($scope.actualPiecesFri), style: 'tableData'}, {text: $filter('currencyFilter')($scope.actualPiecesTotal), style: 'tableData'}, '', ''],
[ { text: '-', colSpan: 11, alignment: 'center'} ],
]
}
},
],
};
pdfMake.createPdf(docDefinition).open();
});
From what I understand I need to create an array that loops when the search filter is set to 'all.'
Not sure how I can do this when I am exporting a ui-grid as a pdf.
Any help is much appreciated