import { data, base64_Turkishfont } from './datasource';
@Component({
selector: 'app-root',
template: `<ejs-grid [dataSource]='data' [allowGrouping]='true' [allowPaging]='true'
[toolbar]='toolbar' (toolbarClick)='toolbarClick($event)'
[allowExcelExport]='true' [pageSettings]='pageSettings' [allowPdfExport]='true'>
<e-columns>
<e-column field='OrderID' headerText='รหัสคำสั่งซื้อ' textAlign='Right' width=90></e-column>
</e-columns>
</ejs-grid>`,
providers: [ToolbarService, PageService, ExcelExportService, PdfExportService]
})
export class AppComponent implements OnInit {
public gridData: Object[];
public toolbar: string[];
public pageSettings: Object;
@ViewChild('grid')
public grid: GridComponent;
. . . . .
toolbarClick(args: ClickEventArgs): void {
let id: any = document.getElementsByClassName('e-grid')[0].id + '_pdfexport';
let grid: any = (document.getElementsByClassName('e-grid')[0] as any).ej2_instances[0];
if (args.item.id === id) {
let pdfExportProperties: PdfExportProperties = {
theme: {
header: {font: new PdfTrueTypeFont(base64_Turkishfont, 12) },
caption: { font: new PdfTrueTypeFont(base64ThaiFont, 10) },
record: { font: new PdfTrueTypeFont(base64ThaiFont, 9) }
}
};
this.grid.pdfExport(pdfExportProperties);
}
}
}
|