all files / grid/renderer/ default-edit-cell.js

100% Statements 47/47
97.62% Branches 41/42
100% Functions 14/14
100% Lines 44/44
11 statements, 6 functions, 9 branches Ignored     
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73          1377×   1266×     1266×   770×       768×     835× 835× 835×           835×   835× 835× 835× 140×         849× 749× 749×          
/* istanbul ignore next */ 
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
define(["require", "exports", "@syncfusion/ej2-base", "../base/util", "@syncfusion/ej2-inputs", "./edit-cell-base"], function (require, exports, ej2_base_1, util_1, ej2_inputs_1, edit_cell_base_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var DefaultEditCell = (function (_super) {
        __extends(DefaultEditCell, _super);
        function DefaultEditCell() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        DefaultEditCell.prototype.create = function (args) {
            var attr = {
                type: 'text', value: !ej2_base_1.isNullOrUndefined(args.value) ? args.value : '', style: 'text-align:' + args.column.textAlign
            };
            return util_1.createEditElement(this.parent, args.column, 'e-field e-input e-defaultcell', attr);
        };
        DefaultEditCell.prototype.read = function (element) {
            if (element.type === 'hidden' && !ej2_base_1.isNullOrUndefined(element.ej2_instances[0]) &&
                !ej2_base_1.isNullOrUndefined(element.ej2_instances[0].textarea)) {
                return element.ej2_instances[0].value;
            }
            else {
                return element.value;
            }
        };
        DefaultEditCell.prototype.write = function (args) {
            var col = args.column;
            var isInline = this.parent.editSettings.mode !== 'Dialog';
            var props = {
                element: args.element, floatLabelType: this.parent.editSettings.mode !== 'Dialog' ? 'Never' : 'Always',
                enableRtl: this.parent.enableRtl, enabled: util_1.isEditable(args.column, args.requestType, args.element),
                placeholder: isInline ? '' : args.column.headerText,
                cssClass: this.parent.cssClass ? this.parent.cssClass : ''
            };
            if (!ej2_base_1.isNullOrUndefined(col.edit) && !ej2_base_1.isNullOrUndefined(col.edit.params) && col.edit.params.multiline) {
                var cellValue = (col.valueAccessor(col.field, args.rowData, col));
                props['value'] = cellValue;
            }
            this.obj = new ej2_inputs_1.TextBox(ej2_base_1.extend(props, col.edit.params));
            this.obj.appendTo(args.element);
            if (this.parent.editSettings.mode === 'Batch') {
                this.obj.element.addEventListener('keydown', this.keyEventHandler);
            }
        };
        DefaultEditCell.prototype.keyEventHandler = function (args) {
            Eif (args.key === 'Enter' || args.key === 'Tab') {
                var evt = new Event('change', { bubbles: false, cancelable: true });
                this.dispatchEvent(evt);
            }
        };
        DefaultEditCell.prototype.destroy = function () {
            if (this.obj && !this.obj.isDestroyed) {
                this.obj.element.removeEventListener('keydown', this.keyEventHandler);
                this.obj.destroy();
            }
        };
        return DefaultEditCell;
    }(edit_cell_base_1.EditCellBase));
    exports.DefaultEditCell = DefaultEditCell;
});