@progress/kendo-angular-grid
Version:
Kendo UI Grid for Angular - high performance data grid with paging, filtering, virtualization, CRUD, and more.
62 lines (61 loc) • 3.25 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 { ChangeDetectorRef, Directive, NgZone } from '@angular/core';
import { EditService } from './edit.service';
import { ToolBarButtonComponent } from '@progress/kendo-angular-toolbar';
import { SelectionService } from '../selection/selection.service';
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 "../selection/selection.service";
import * as i4 from "../common/provider.service";
/**
* Represents the `remove` command in the Grid. Apply this directive to any `kendo-toolbar-button`
* element inside a ToolbarComponent used in the Grid.
*
* When you click the toolbar button with this directive, the
* [`remove`]({% slug api_grid_gridcomponent %}#toc-remove) event fires.
*
* @example
* ```html
* <kendo-grid>
* <kendo-toolbar>
* <kendo-toolbar-button text="Remove row" kendoGridRemoveTool></kendo-toolbar-button>
* </kendo-toolbar>
* </kendo-grid>
* ```
* @remarks
* Applied to: {@link ToolBarButtonComponent}.
*/
export class RemoveCommandToolbarDirective extends ToolbarEditingToolBase {
editService;
selection;
constructor(editService, host, selection, ctx, zone, cdr) {
super(host, ToolbarToolName.remove, ctx, zone, cdr, editService, selection);
this.editService = editService;
this.selection = selection;
}
/**
* @hidden
*/
onClick(e) {
e.preventDefault();
if (this.isSelectionPresent) {
this.editService.remove(this.lastSelectionIndex);
}
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: RemoveCommandToolbarDirective, deps: [{ token: i1.EditService }, { token: i2.ToolBarButtonComponent }, { token: i3.SelectionService }, { token: i4.ContextService }, { token: i0.NgZone }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.14", type: RemoveCommandToolbarDirective, isStandalone: true, selector: "[kendoGridRemoveTool]", usesInheritance: true, ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: RemoveCommandToolbarDirective, decorators: [{
type: Directive,
args: [{
selector: '[kendoGridRemoveTool]',
standalone: true
}]
}], ctorParameters: () => [{ type: i1.EditService }, { type: i2.ToolBarButtonComponent }, { type: i3.SelectionService }, { type: i4.ContextService }, { type: i0.NgZone }, { type: i0.ChangeDetectorRef }] });