@progress/kendo-angular-grid
Version:
Kendo UI Grid for Angular - high performance data grid with paging, filtering, virtualization, CRUD, and more.
67 lines (66 loc) • 3.14 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, Input } from '@angular/core';
import { RowEditingDirectiveBase } from './row-editing-directive-base';
import { GridComponent } from '../grid.component';
import { LocalDataChangesService } from '../editing/local-data-changes.service';
import * as i0 from "@angular/core";
import * as i1 from "../grid.component";
import * as i2 from "../editing/local-data-changes.service";
/**
* A directive which encapsulates the editing operations of the Grid when using
* the Template-Driven Angular Forms ([see example]({% slug editing_directives_grid %}#toc-template-editing-directive)).
*/
export class TemplateEditingDirective extends RowEditingDirectiveBase {
grid;
localDataChangesService;
/**
* The function that creates the `dataItem` for the new rows.
*/
createNewItem;
dataItem;
originalValues;
constructor(grid, localDataChangesService) {
super(grid, localDataChangesService);
this.grid = grid;
this.localDataChangesService = localDataChangesService;
}
editHandler(args) {
super.editHandler(args);
this.dataItem = args.dataItem;
this.originalValues = {};
this.editService.assignValues(this.originalValues, this.dataItem);
}
closeEditor(rowIndex) {
if (this.dataItem) {
this.editService.assignValues(this.dataItem, this.originalValues);
}
super.closeEditor(rowIndex);
}
createModel(args) {
if (args.isNew) {
return this.createNewItem();
}
}
saveModel(args) {
return args.dataItem;
}
clean() {
super.clean();
delete this.dataItem;
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: TemplateEditingDirective, deps: [{ token: i1.GridComponent }, { token: i2.LocalDataChangesService }], target: i0.ɵɵFactoryTarget.Directive });
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: TemplateEditingDirective, isStandalone: true, selector: "[kendoGridTemplateEditing]", inputs: { createNewItem: ["kendoGridTemplateEditing", "createNewItem"] }, usesInheritance: true, ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: TemplateEditingDirective, decorators: [{
type: Directive,
args: [{
selector: '[kendoGridTemplateEditing]',
standalone: true
}]
}], ctorParameters: function () { return [{ type: i1.GridComponent }, { type: i2.LocalDataChangesService }]; }, propDecorators: { createNewItem: [{
type: Input,
args: ['kendoGridTemplateEditing']
}] } });