UNPKG

@syncfusion/ej2-grids

Version:

Feature-rich JavaScript datagrid (datatable) control with built-in support for editing, filtering, grouping, paging, sorting, and exporting to Excel.

55 lines (54 loc) 2.5 kB
import { extend, Internationalization } from '@syncfusion/ej2-base'; import { NumericTextBox } from '@syncfusion/ej2-inputs'; import { isEditable, getComplexFieldID, getObject, createEditElement, parentsUntil, isCellHaveWidth } from '../base/util'; /** * `NumericEditCell` is used to handle numeric cell type editing. * * @hidden */ var NumericEditCell = /** @class */ (function () { function NumericEditCell(parent) { this.parent = parent; } NumericEditCell.prototype.keyEventHandler = function (args) { if (args.keyCode === 13 || args.keyCode === 9) { var evt = document.createEvent('HTMLEvents'); evt.initEvent('change', false, true); // eslint-disable-next-line @typescript-eslint/no-explicit-any this.dispatchEvent(evt); } }; NumericEditCell.prototype.create = function (args) { this.instances = new Internationalization(this.parent.locale); return createEditElement(this.parent, args.column, 'e-field', {}); }; // eslint-disable-next-line @typescript-eslint/no-unused-vars NumericEditCell.prototype.read = function (element) { return this.obj.value; }; NumericEditCell.prototype.write = function (args) { var col = args.column; var isInline = this.parent.editSettings.mode !== 'Dialog'; this.obj = new NumericTextBox(extend({ value: parseFloat(getObject(args.column.field, args.rowData)), enableRtl: this.parent.enableRtl, placeholder: isInline ? '' : args.column.headerText, enabled: isEditable(args.column, args.requestType, args.element) && isCellHaveWidth(parentsUntil(args.element, 'e-rowcell')), floatLabelType: this.parent.editSettings.mode !== 'Dialog' ? 'Never' : 'Always', locale: this.parent.locale, cssClass: this.parent.cssClass ? this.parent.cssClass : null }, col.edit.params)); args.element.setAttribute('name', getComplexFieldID(args.column.field)); this.obj.appendTo(args.element); this.obj.element.addEventListener('keydown', this.keyEventHandler); }; NumericEditCell.prototype.destroy = function () { if (this.obj && !this.obj.isDestroyed) { this.obj.element.removeEventListener('keydown', this.keyEventHandler); this.obj.destroy(); this.obj.element.remove(); } }; return NumericEditCell; }()); export { NumericEditCell };