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

86.67% Statements 26/30
68.75% Branches 11/16
88.89% Functions 8/9
86.67% Lines 26/30
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   38×   45× 45×             45× 45× 45×                     45× 45×   36×   22× 22×                 42× 42×          
define(["require", "exports", "@syncfusion/ej2-base", "@syncfusion/ej2-base", "@syncfusion/ej2-dropdowns", "@syncfusion/ej2-data", "../base/util", "../base/util"], function (require, exports, ej2_base_1, ej2_base_2, ej2_dropdowns_1, ej2_data_1, util_1, util_2) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var DropDownEditCell = (function () {
        function DropDownEditCell(parent) {
            this.parent = parent;
        }
        DropDownEditCell.prototype.create = function (args) {
            var complexFieldName = util_1.getComplexFieldID(args.column.field);
            return ej2_base_2.createElement('input', {
                className: 'e-field', attrs: {
                    id: this.parent.element.id + complexFieldName,
                    name: complexFieldName, type: 'text', 'e-mappinguid': args.column.uid,
                }
            });
        };
        DropDownEditCell.prototype.write = function (args) {
            this.column = args.column;
            var isInline = this.parent.editSettings.mode !== 'Dialog';
            this.obj = new ej2_dropdowns_1.DropDownList(ej2_base_1.extend({
                dataSource: this.parent.dataSource instanceof ej2_data_1.DataManager ?
                    this.parent.dataSource : new ej2_data_1.DataManager(this.parent.dataSource),
                query: new ej2_data_1.Query().select(args.column.field), enabled: util_1.isEditable(args.column, args.requestType, args.element),
                fields: { value: args.column.field },
                value: util_1.getObject(args.column.field, args.rowData),
                enableRtl: this.parent.enableRtl, actionComplete: this.ddActionComplete.bind(this),
                placeholder: isInline ? '' : args.column.headerText, popupHeight: '200px',
                floatLabelType: isInline ? 'Never' : 'Always', open: this.dropDownOpen.bind(this),
                sortOrder: 'Ascending'
            }, args.column.edit.params));
            this.obj.appendTo(args.element);
            args.element.setAttribute('name', util_1.getComplexFieldID(args.column.field));
        };
        DropDownEditCell.prototype.read = function (element) {
            return element.ej2_instances[0].value;
        };
        DropDownEditCell.prototype.ddActionComplete = function (e) {
            e.result = ej2_data_1.DataUtil.distinct(e.result, this.column.isForeignColumn() ? this.column.foreignKeyField : this.column.field, true);
            if (this.column.dataSource) {
                this.column.dataSource.dataSource.json = e.result;
            }
        };
        DropDownEditCell.prototype.dropDownOpen = function (args) {
            var dlgElement = util_2.parentsUntil(this.obj.element, 'e-dialog');
            if (this.parent.editSettings.mode === 'Dialog' && !ej2_base_1.isNullOrUndefined(dlgElement)) {
                var dlgObj = this.parent.element.querySelector('#' + dlgElement.id).ej2_instances[0];
                args.popup.element.style.zIndex = (dlgObj.zIndex + 1).toString();
            }
        };
        DropDownEditCell.prototype.destroy = function () {
            Eif (this.obj) {
                this.obj.destroy();
            }
        };
        return DropDownEditCell;
    }());
    exports.DropDownEditCell = DropDownEditCell;
});