define(["require", "exports", "@syncfusion/ej2-base", "@syncfusion/ej2-data", "../services/value-formatter", "../base/util"], function (require, exports, ej2_base_1, ej2_data_1, value_formatter_1, util_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var Column = (function () {
        function Column(options) {
            var _this = this;
            this.allowSorting = true;
            this.allowResizing = true;
            this.allowFiltering = true;
            this.allowGrouping = true;
            this.allowReordering = true;
            this.showColumnMenu = true;
            this.enableGroupByFormat = false;
            this.allowEditing = true;
            this.filter = {};
            this.showInColumnChooser = true;
            this.edit = {};
            this.sortDirection = 'Descending';
            this.getEditTemplate = function () { return _this.editTemplateFn; };
            ej2_base_1.merge(this, options);
            this.uid = util_1.getUid('grid-column');
            var valueFormatter = new value_formatter_1.ValueFormatter();
            if (options.format && (options.format.skeleton || options.format.format)) {
                this.setFormatter(valueFormatter.getFormatFunction(options.format));
                this.setParser(valueFormatter.getParserFunction(options.format));
            }
            if (!this.field) {
                this.allowFiltering = false;
                this.allowGrouping = false;
                this.allowSorting = false;
            }
            if (this.commands && !this.textAlign) {
                this.textAlign = 'Right';
            }
            if (this.template || this.commandsTemplate) {
                this.templateFn = util_1.templateCompiler(this.template || this.commandsTemplate);
            }
            if (this.headerTemplate) {
                this.headerTemplateFn = util_1.templateCompiler(this.headerTemplate);
            }
            Iif (this.filter.itemTemplate) {
                this.fltrTemplateFn = util_1.templateCompiler(this.filter.itemTemplate);
            }
            if (this.editTemplate) {
                this.editTemplateFn = util_1.templateCompiler(this.editTemplate);
            }
            if (this.isForeignColumn() && (ej2_base_1.isNullOrUndefined(this.editType) || this.editType === 'dropdownedit')) {
                this.editType = 'dropdownedit';
                this.edit.params = ej2_base_1.extend({
                    dataSource: this.dataSource,
                    query: new ej2_data_1.Query(), fields: { value: this.foreignKeyField || this.field, text: this.foreignKeyValue }
                }, this.edit.params);
            }
            if (this.sortComparer) {
                var a_1 = this.sortComparer;
                this.sortComparer = function comparer(x, y) {
                    if (typeof a_1 === 'string') {
                        a_1 = util_1.getObject(a_1, window);
                    }
                    if (this.sortDirection === 'Descending') {
                        var z = x;
                        x = y;
                        y = z;
                    }
                    return a_1(x, y);
                };
            }
            if (!this.sortComparer && this.isForeignColumn()) {
                this.sortComparer = function (x, y) {
                    x = util_1.getObject(_this.foreignKeyValue, util_1.getForeignData(_this, {}, x)[0]);
                    y = util_1.getObject(_this.foreignKeyValue, util_1.getForeignData(_this, {}, y)[0]);
                    return _this.sortDirection === 'Descending' ? ej2_data_1.DataUtil.fnDescending(x, y) : ej2_data_1.DataUtil.fnAscending(x, y);
                };
            }
        }
        Column.prototype.getSortDirection = function () {
            return this.sortDirection;
        };
        Column.prototype.setSortDirection = function (direction) {
            this.sortDirection = direction;
        };
        Column.prototype.setProperties = function (column) {
            var keys = Object.keys(column);
            for (var i = 0; i < keys.length; i++) {
                this[keys[i]] = column[keys[i]];
            }
        };
        Column.prototype.isForeignColumn = function () {
            return !!(this.dataSource && this.foreignKeyValue);
        };
        Column.prototype.getFormatter = function () {
            return this.formatFn;
        };
        Column.prototype.setFormatter = function (value) {
            this.formatFn = value;
        };
        Column.prototype.getParser = function () {
            return this.parserFn;
        };
        Column.prototype.setParser = function (value) {
            this.parserFn = value;
        };
        Column.prototype.getColumnTemplate = function () {
            return this.templateFn;
        };
        Column.prototype.getHeaderTemplate = function () {
            return this.headerTemplateFn;
        };
        Column.prototype.getFilterItemTemplate = function () {
            return this.fltrTemplateFn;
        };
        Column.prototype.getDomSetter = function () {
            return this.disableHtmlEncode ? 'textContent' : 'innerHTML';
        };
        return Column;
    }());
    exports.Column = Column;
});
  |