@progress/kendo-angular-treelist
Version:
Kendo UI TreeList for Angular - Display hierarchical data in an Angular tree grid view that supports sorting, filtering, paging, and much more.
65 lines (64 loc) • 3 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 { Directive } from '@angular/core';
import { ToolBarButtonComponent } from '@progress/kendo-angular-toolbar';
import { Subscription } from 'rxjs';
import { fileExcelIcon } from '@progress/kendo-svg-icons';
import { ExcelService } from './excel.service';
import * as i0 from "@angular/core";
import * as i1 from "./excel.service";
import * as i2 from "@progress/kendo-angular-toolbar";
/**
* Represents the `export-to-Excel` toolbar tool of the TreeList. Apply this directive to any `kendo-toolbar-button` element inside a ToolbarComponent used in the TreeList.
*
* When the user clicks a button with this directive, the [excelExport]({% slug api_treelist_treelistcomponent %}#toc-excelexport) event fires ([see example]({% slug excelexport_treelist %})).
*
* @example
* ```html
* <kendo-treelist>
* <kendo-toolbar>
* <kendo-toolbar-button text="Excel Export" kendoTreeListExcelTool></kendo-toolbar-button>
* </kendo-toolbar>
* <kendo-treelist-excel fileName="TreeList.xlsx">
* </kendo-treelist-excel>
* </kendo-treelist>
* ```
* @remarks
* Applied to: {@link ToolBarButtonComponent}
*/
export class ExcelCommandToolbarDirective {
excelService;
host;
clickSub = new Subscription();
constructor(excelService, host) {
this.excelService = excelService;
this.host = host;
}
ngOnInit() {
this.clickSub = this.host.click.subscribe(e => this.onClick(e));
this.host.className = 'k-grid-excel';
this.host.svgIcon = fileExcelIcon;
this.host.icon = 'file-excel';
}
ngOnDestroy() {
this.clickSub.unsubscribe();
}
/**
* @hidden
*/
onClick(e) {
e.preventDefault();
this.excelService.exportClick.emit();
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ExcelCommandToolbarDirective, deps: [{ token: i1.ExcelService }, { token: i2.ToolBarButtonComponent }], target: i0.ɵɵFactoryTarget.Directive });
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: ExcelCommandToolbarDirective, isStandalone: true, selector: "[kendoTreeListExcelTool]", ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ExcelCommandToolbarDirective, decorators: [{
type: Directive,
args: [{
selector: '[kendoTreeListExcelTool]',
standalone: true
}]
}], ctorParameters: function () { return [{ type: i1.ExcelService }, { type: i2.ToolBarButtonComponent }]; } });