@progress/kendo-angular-grid
Version:
Kendo UI Grid for Angular - high performance data grid with paging, filtering, virtualization, CRUD, and more.
55 lines (54 loc) • 2.88 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 { markAllAsTouched } from './utils';
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
* Reactive Forms ([see example](slug:editing_directives_grid#toc-reactive-editing-directive)).
*/
export class ReactiveEditingDirective extends RowEditingDirectiveBase {
grid;
localDataChangesService;
/**
* The function that creates the `FormGroup` for the edited model.
*/
createFormGroup;
constructor(grid, localDataChangesService) {
super(grid, localDataChangesService);
this.grid = grid;
this.localDataChangesService = localDataChangesService;
}
createModel(args) {
return this.createFormGroup(args);
}
saveModel({ dataItem, formGroup, isNew }) {
if (!formGroup.dirty && !isNew) {
return;
}
if (formGroup.valid) {
this.editService.assignValues(dataItem, formGroup.value);
return dataItem;
}
markAllAsTouched(formGroup);
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ReactiveEditingDirective, deps: [{ token: i1.GridComponent }, { token: i2.LocalDataChangesService }], target: i0.ɵɵFactoryTarget.Directive });
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: ReactiveEditingDirective, isStandalone: true, selector: "[kendoGridReactiveEditing]", inputs: { createFormGroup: ["kendoGridReactiveEditing", "createFormGroup"] }, usesInheritance: true, ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ReactiveEditingDirective, decorators: [{
type: Directive,
args: [{
selector: '[kendoGridReactiveEditing]',
standalone: true
}]
}], ctorParameters: function () { return [{ type: i1.GridComponent }, { type: i2.LocalDataChangesService }]; }, propDecorators: { createFormGroup: [{
type: Input,
args: ['kendoGridReactiveEditing']
}] } });