@progress/kendo-angular-grid
Version:
Kendo UI Grid for Angular - high performance data grid with paging, filtering, virtualization, CRUD, and more.
99 lines (98 loc) • 4.78 kB
JavaScript
/**-----------------------------------------------------------------------------------------
* Copyright © 2025 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the project root for more information
*-------------------------------------------------------------------------------------------*/
import { Component, HostListener, HostBinding, ElementRef, Renderer2 as Renderer, NgZone } from '@angular/core';
import { Button } from '@progress/kendo-angular-buttons';
import { ContextService } from '../common/provider.service';
import { PDFService } from './pdf.service';
import { IconWrapperComponent } from '@progress/kendo-angular-icons';
import { NgClass } from '@angular/common';
import * as i0 from "@angular/core";
import * as i1 from "./pdf.service";
import * as i2 from "../common/provider.service";
/**
* Represents the PDF export command of the Grid.
* Apply this directive to any `button` element inside a [ToolbarTemplate]({% slug api_grid_commandcolumncomponent %}).
* When you click a button with this directive, the [`pdfExport`]({% slug api_grid_gridcomponent %}#toc-pdfexport) event fires. ([See example]({% slug pdfexport_grid %})).
*
* @example
* ```html
* <kendo-grid>
* <ng-template kendoGridToolbarTemplate>
* <button kendoGridPDFCommand>Export to PDF</button>
* </ng-template>
* <kendo-grid-pdf fileName="products.pdf"></kendo-grid-pdf>
* </kendo-grid>
* ```
*/
export class PDFCommandDirective extends Button {
pdfService;
/**
* @hidden
*/
onClick(e) {
e.preventDefault();
this.pdfService.exportClick.emit();
}
/**
* @hidden
*/
get pdfClass() {
return true;
}
constructor(pdfService, element, renderer, ctx, ngZone) {
super(element, renderer, null, ctx.localization, ngZone);
this.pdfService = pdfService;
this.ngZone = ngZone;
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: PDFCommandDirective, deps: [{ token: i1.PDFService }, { token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i2.ContextService }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: PDFCommandDirective, isStandalone: true, selector: "[kendoGridPDFCommand]", host: { listeners: { "click": "onClick($event)" }, properties: { "class.k-grid-pdf": "this.pdfClass" } }, usesInheritance: true, ngImport: i0, template: `
(icon || svgIcon) {
<kendo-icon-wrapper
innerCssClass="k-button-icon"
[name]="icon"
[svgIcon]="svgIcon"></kendo-icon-wrapper>
}
(imageUrl) {
<span class="k-button-icon k-icon">
<img [src]="imageUrl" class="k-image" role="presentation" />
</span>
}
(iconClass) {
<span class="k-button-icon" [ngClass]="iconClass"></span>
}
<span class="k-button-text"><ng-content></ng-content></span>
`, isInline: true, dependencies: [{ kind: "component", type: IconWrapperComponent, selector: "kendo-icon-wrapper", inputs: ["name", "svgIcon", "innerCssClass", "customFontClass", "size"], exportAs: ["kendoIconWrapper"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: PDFCommandDirective, decorators: [{
type: Component,
args: [{
selector: '[kendoGridPDFCommand]',
template: `
(icon || svgIcon) {
<kendo-icon-wrapper
innerCssClass="k-button-icon"
[name]="icon"
[svgIcon]="svgIcon"></kendo-icon-wrapper>
}
(imageUrl) {
<span class="k-button-icon k-icon">
<img [src]="imageUrl" class="k-image" role="presentation" />
</span>
}
(iconClass) {
<span class="k-button-icon" [ngClass]="iconClass"></span>
}
<span class="k-button-text"><ng-content></ng-content></span>
`,
standalone: true,
imports: [IconWrapperComponent, NgClass]
}]
}], ctorParameters: () => [{ type: i1.PDFService }, { type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i2.ContextService }, { type: i0.NgZone }], propDecorators: { onClick: [{
type: HostListener,
args: ['click', ['$event']]
}], pdfClass: [{
type: HostBinding,
args: ['class.k-grid-pdf']
}] } });