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

100% Statements 28/28
92.86% Branches 13/14
100% Functions 8/8
100% Lines 28/28
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   97×       79× 79×   55×   75× 75× 75×                 75× 75× 75×   85× 71× 71×          
define(["require", "exports", "@syncfusion/ej2-base", "@syncfusion/ej2-inputs", "../base/util"], function (require, exports, ej2_base_1, ej2_inputs_1, util_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var NumericEditCell = (function () {
        function NumericEditCell(parent) {
            this.parent = parent;
        }
        NumericEditCell.prototype.keyEventHandler = function (args) {
            Eif (args.keyCode === 13 || args.keyCode === 9) {
                var evt = document.createEvent('HTMLEvents');
                evt.initEvent('change', false, true);
                this.dispatchEvent(evt);
            }
        };
        NumericEditCell.prototype.create = function (args) {
            this.instances = new ej2_base_1.Internationalization(this.parent.locale);
            return util_1.createEditElement(this.parent, args.column, 'e-field', {});
        };
        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 ej2_inputs_1.NumericTextBox(ej2_base_1.extend({
                value: parseFloat(util_1.getObject(args.column.field, args.rowData)),
                enableRtl: this.parent.enableRtl,
                placeholder: isInline ? '' : args.column.headerText,
                enabled: util_1.isEditable(args.column, args.requestType, args.element),
                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', util_1.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();
            }
        };
        return NumericEditCell;
    }());
    exports.NumericEditCell = NumericEditCell;
});