UNPKG

@progress/kendo-angular-grid

Version:

Kendo UI Grid for Angular - high performance data grid with paging, filtering, virtualization, CRUD, and more.

93 lines (92 loc) 4.91 kB
/**----------------------------------------------------------------------------------------- * 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 { ExcelService } from './excel.service'; import { IconWrapperComponent } from '@progress/kendo-angular-icons'; import { NgIf, NgClass } from '@angular/common'; import * as i0 from "@angular/core"; import * as i1 from "./excel.service"; import * as i2 from "../common/provider.service"; /** * Represents the `export-to-Excel` command of the Grid. You can apply this * directive to any `button` element inside a * [ToolbarTemplate]({% slug api_grid_toolbartemplatedirective %}). * When the user clicks a button associated with the directive, the * [excelExport]({% slug api_grid_gridcomponent %}#toc-excelexport) event * fires ([see example]({% slug excelexport_grid %})). * * @example * ```html * <kendo-grid> * <ng-template kendoGridToolbarTemplate> * <button kendoGridExcelCommand>Export to Excel</button> * </ng-template> * <kendo-grid-excel fileName="Grid.xlsx"> * </kendo-grid-excel> * </kendo-grid> * ``` */ export class ExcelCommandDirective extends Button { excelService; /** * @hidden */ onClick(e) { e.preventDefault(); this.excelService.exportClick.emit(); } /** * @hidden */ get excelClass() { return true; } constructor(excelService, element, renderer, ctx, ngZone) { super(element, renderer, null, ctx.localization, ngZone); this.excelService = excelService; this.ngZone = ngZone; } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ExcelCommandDirective, deps: [{ token: i1.ExcelService }, { token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i2.ContextService }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component }); static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: ExcelCommandDirective, isStandalone: true, selector: "[kendoGridExcelCommand]", host: { listeners: { "click": "onClick($event)" }, properties: { "class.k-grid-excel": "this.excelClass" } }, usesInheritance: true, ngImport: i0, template: ` <kendo-icon-wrapper *ngIf="icon || svgIcon" innerCssClass="k-button-icon" [name]="icon" [svgIcon]="svgIcon"></kendo-icon-wrapper> <span *ngIf="imageUrl" class="k-button-icon k-icon"> <img [src]="imageUrl" class="k-image" role="presentation" /> </span> <span *ngIf="iconClass" class="k-button-icon" [ngClass]="iconClass"></span> <span class="k-button-text"><ng-content></ng-content></span> `, isInline: true, dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { 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: "16.2.12", ngImport: i0, type: ExcelCommandDirective, decorators: [{ type: Component, args: [{ selector: '[kendoGridExcelCommand]', template: ` <kendo-icon-wrapper *ngIf="icon || svgIcon" innerCssClass="k-button-icon" [name]="icon" [svgIcon]="svgIcon"></kendo-icon-wrapper> <span *ngIf="imageUrl" class="k-button-icon k-icon"> <img [src]="imageUrl" class="k-image" role="presentation" /> </span> <span *ngIf="iconClass" class="k-button-icon" [ngClass]="iconClass"></span> <span class="k-button-text"><ng-content></ng-content></span> `, standalone: true, imports: [NgIf, IconWrapperComponent, NgClass] }] }], ctorParameters: function () { return [{ type: i1.ExcelService }, { type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i2.ContextService }, { type: i0.NgZone }]; }, propDecorators: { onClick: [{ type: HostListener, args: ['click', ['$event']] }], excelClass: [{ type: HostBinding, args: ['class.k-grid-excel'] }] } });