define(["require", "exports", "@syncfusion/ej2-base", "../base/util", "../base/constant"], function (require, exports, ej2_base_1, util_1, events) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var ShowHide = (function () {
function ShowHide(parent) {
this.parent = parent;
}
ShowHide.prototype.show = function (columnName, showBy) {
var keys = this.getToggleFields(columnName);
var columns = this.getColumns(keys, showBy);
this.parent.notify(events.tooltipDestroy, { module: 'edit' });
columns.forEach(function (value) {
value.visible = true;
});
this.setVisible(columns);
};
ShowHide.prototype.hide = function (columnName, hideBy) {
var keys = this.getToggleFields(columnName);
var columns = this.getColumns(keys, hideBy);
this.parent.notify(events.tooltipDestroy, { module: 'edit' });
columns.forEach(function (value) {
value.visible = false;
});
this.setVisible(columns);
};
ShowHide.prototype.getToggleFields = function (key) {
var finalized = [];
if (typeof key === 'string') {
finalized = [key];
}
else {
finalized = key;
}
return finalized;
};
ShowHide.prototype.getColumns = function (keys, getKeyBy) {
var _this = this;
var columns = util_1.iterateArrayOrObject(keys, function (key, index) {
return util_1.iterateArrayOrObject(_this.parent.getColumns(), function (item, index) {
if (item[getKeyBy] === key) {
return item;
}
return undefined;
})[0];
});
return columns;
};
ShowHide.prototype.setVisible = function (columns) {
Iif (util_1.isActionPrevent(this.parent)) {
this.parent.notify(events.preventBatch, {
instance: this, handler: this.setVisible,
arg1: columns
});
return;
}
columns = ej2_base_1.isNullOrUndefined(columns) ? this.parent.getColumns() : columns;
if (this.parent.allowSelection && this.parent.getSelectedRecords().length) {
this.parent.clearSelection();
}
this.parent.notify(events.columnVisibilityChanged, columns);
Iif (this.parent.columnQueryMode !== 'All') {
this.parent.refresh();
}
};
return ShowHide;
}());
exports.ShowHide = ShowHide;
});
|