UNPKG

@progress/kendo-angular-grid

Version:

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

60 lines (59 loc) 3.11 kB
/**----------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the project root for more information *-------------------------------------------------------------------------------------------*/ import { ChangeDetectorRef, Directive, NgZone } from '@angular/core'; import { EditService } from './edit.service'; import { ToolBarButtonComponent } from '@progress/kendo-angular-toolbar'; import { ContextService } from '../common/provider.service'; import { ToolbarEditingToolBase } from './toolbar-editing-tool-base.directive'; import { ToolbarToolName } from '../navigation/toolbar-tool-name'; import * as i0 from "@angular/core"; import * as i1 from "./edit.service"; import * as i2 from "@progress/kendo-angular-toolbar"; import * as i3 from "../common/provider.service"; /** * Represents the command for adding a new item to the Grid. * You can apply this directive to any `kendo-toolbar-button` element inside a ToolbarComponent used in the Grid. * When you click the toolbar button associated with the directive, the [`add`]({% slug api_grid_gridcomponent %}#toc-add) event triggers ([see example]({% slug basics_editing_grid %})). * * @example * ```html * <kendo-grid> * <kendo-toolbar> * <kendo-toolbar-button text="Add new" kendoGridAddTool></kendo-toolbar-button> * </kendo-toolbar> * </kendo-grid> * ``` * @remarks * Applied to: {@link ToolBarButtonComponent}. */ export class AddCommandToolbarDirective extends ToolbarEditingToolBase { editService; host; constructor(editService, host, ctx, zone, cdr) { super(host, ToolbarToolName.add, ctx, zone, cdr, editService); this.editService = editService; this.host = host; } ngOnInit() { super.ngOnInit(); this.host.className = 'k-grid-add-command'; } /** * @hidden */ onClick(e) { e.preventDefault(); this.editService.beginAdd(); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: AddCommandToolbarDirective, deps: [{ token: i1.EditService }, { token: i2.ToolBarButtonComponent }, { token: i3.ContextService }, { token: i0.NgZone }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive }); static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.14", type: AddCommandToolbarDirective, isStandalone: true, selector: "[kendoGridAddTool]", usesInheritance: true, ngImport: i0 }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: AddCommandToolbarDirective, decorators: [{ type: Directive, args: [{ selector: '[kendoGridAddTool]', standalone: true }] }], ctorParameters: () => [{ type: i1.EditService }, { type: i2.ToolBarButtonComponent }, { type: i3.ContextService }, { type: i0.NgZone }, { type: i0.ChangeDetectorRef }] });