Adrew Adrew - 1 year ago 44
AngularJS Question

Calling an expression to my table using pdf make

I have created a table using pdf make and I want each cell (Region, Group, etc) to be displayed in my view.

Here is the table in the js exported using Pdf Header:

exporterPdfHeader: {
margin: [30, 5, 30, 15],
table: {

widths: [ '*', '*', '*' /*, '*'*/ ],

body: [
[ 'Region: ', 'Group: ', 'MC: ' ],
[ 'District #: ', 'Route #: ', 'Week Ending Date: ' ]

]
}

},


Below is an example of my view

<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>


I want the cell that contains Region to call this argument and be exported using pdf make, how can i do this? Any help is greatly appreciated

Answer Source

I first created a scope test outside the gridoptions. Then set the scope to the getData function.

$scope.test = ''

$scope.getData = function(){
...
$scope.test = $scope.searchFilter.region.description;
}

This is the expression declared in the html

    {{searchFilter.region.description}}</span>

Finally I set the pdfheader within the broadcast

$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();
});
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download