1 import {Component, Input, TemplateRef, ViewChild} from '@angular/core';
2 import {ProgressDialogComponent} from '@eg/share/dialog/progress.component';
3 import {PrintService} from '@eg/share/print/print.service';
4 import {GridContext} from '@eg/share/grid/grid';
7 selector: 'eg-grid-print',
8 templateUrl: './grid-print.component.html'
13 export class GridPrintComponent {
15 @Input() gridContext: GridContext;
16 @ViewChild('printTemplate', { static: true }) private printTemplate: TemplateRef<any>;
17 @ViewChild('progressDialog', { static: true })
18 private progressDialog: ProgressDialogComponent;
20 constructor(private printer: PrintService) {}
23 this.progressDialog.open();
24 const columns = this.gridContext.columnSet.displayColumns();
25 const textItems = {columns: columns, rows: []};
27 // Warn on missing print value generators for cells using templates.
28 columns.forEach(col => {
29 if (col.cellTemplate && !col.cellPrintValue) {
30 console.warn("No print value generator set for: " + col.name);
34 this.gridContext.getAllRowsAsText().subscribe(
36 this.progressDialog.increment();
37 textItems.rows.push(row);
39 err => this.progressDialog.close(),
41 this.progressDialog.close();
43 template: this.printTemplate,
44 contextData: textItems,
45 printContext: 'default'