igniteui-react-grids
Version:
Ignite UI React grid components.
205 lines (204 loc) • 5.39 kB
JavaScript
import { IgrGridCellIdentifier } from "./igr-grid-cell-identifier";
import { IgrColumn } from "./igr-column";
import { GridEditEventArgsDetail as GridEditEventArgsDetail_internal } from "./GridEditEventArgsDetail";
import { ensureBool } from "igniteui-react-core";
/**
* Represents event arguments related to grid editing.
* The event is cancelable
* It contains information about the row and the column, as well as the old and nwe value of the element/cell
*/
export class IgrGridEditEventArgsDetail {
createImplementation() {
return new GridEditEventArgsDetail_internal();
}
get nativeElement() {
return this._implementation.nativeElement;
}
/**
* @hidden
*/
get i() {
return this._implementation;
}
onImplementationCreated() {
}
constructor() {
this.mounted = false;
this._implementation = this.createImplementation();
this._implementation.externalObject = this;
this.onImplementationCreated();
if (this._initializeAdapters) {
this._initializeAdapters();
}
}
_provideImplementation(i) {
this._implementation = i;
this._implementation.externalObject = this;
this.onImplementationCreated();
if (this._initializeAdapters) {
this._initializeAdapters();
}
}
/**
* Provides the ability to cancel the event.
*/
get cancel() {
return this.i.f;
}
set cancel(v) {
this.i.f = ensureBool(v);
}
/**
* @deprecated Use the `rowKey` property instead.
*/
get rowID() {
return this.i.o;
}
set rowID(v) {
this.i.o = v;
}
/**
* @deprecated Use the `rowKey` property instead.
*/
get primaryKey() {
return this.i.m;
}
set primaryKey(v) {
this.i.m = v;
}
get rowKey() {
return this.i.p;
}
set rowKey(v) {
this.i.p = v;
}
get cellID() {
const r = this.i.c;
if (r == null) {
return null;
}
if (!r.externalObject) {
let e = new IgrGridCellIdentifier();
if (r.$type) {
e._implementation = r;
}
else {
if (e.i.setNativeElement) {
e.i.setNativeElement(r);
}
}
r.externalObject = e;
}
return r.externalObject;
}
set cellID(v) {
v == null ? this.i.c = null : this.i.c = v.i;
}
/**
* `rowData` represents the updated/committed data of the row after the edit (newValue)
* The only case rowData (of the current object) is used directly, is when there is no rowEditing or transactions enabled
*/
get rowData() {
return this.i.n;
}
set rowData(v) {
this.i.n = v;
}
/**
* Represents the previous (before editing) value of the edited cell.
* It's used when the event has been stopped/exited.
*/
get oldValue() {
return this.i.l;
}
set oldValue(v) {
this.i.l = v;
}
/**
* Optional
* Represents the value, that is being entered in the edited cell
* When there is no `newValue` and the event has ended, the value of the cell returns to the `oldValue`
*/
get newValue() {
return this.i.k;
}
set newValue(v) {
this.i.k = v;
}
/**
* Optional
* Represents the column information of the edited cell
*/
get column() {
const r = this.i.a;
if (r == null) {
return null;
}
if (!r.externalObject) {
let e = IgrColumn._createFromInternal(r);
if (e) {
e._implementation = r;
}
r.externalObject = e;
}
return r.externalObject;
}
set column(v) {
v == null ? this.i.a = null : this.i.a = v.i;
}
/**
* Optional
* Represents the grid instance that owns the edit event.
*/
get owner() {
const r = this.i.b;
if (r == null) {
return null;
}
return r.externalObject;
}
set owner(v) {
v == null ? this.i.b = null : this.i.b = v.i;
}
/**
* Optional
* Indicates if the editing consists of adding a new row
*/
get isAddRow() {
return this.i.g;
}
set isAddRow(v) {
this.i.g = ensureBool(v);
}
/**
* Optional
* Indicates if the new value would be valid.
* It can be set to return the result of the methods for validation of the grid
*/
get valid() {
return this.i.h;
}
set valid(v) {
this.i.h = ensureBool(v);
}
findByName(name) {
if (this.findEphemera) {
if (name && name.indexOf("@@e:") == 0) {
return this.findEphemera(name);
}
}
if (this.cellID && this.cellID.name && this.cellID.name == name) {
return this.cellID;
}
if (this.column && this.column.name && this.column.name == name) {
return this.column;
}
if (this.owner && this.owner.name && this.owner.name == name) {
return this.owner;
}
return null;
}
setNativeElement(element) {
this.i.setNativeElement(element);
}
}