all files / treegrid/actions/ reorder.js

100% Statements 31/31
100% Branches 4/4
100% Functions 8/8
100% Lines 31/31
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     11395×           13× 13× 13×            
define(["require", "exports", "@syncfusion/ej2-grids"], function (require, exports, ej2_grids_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var Reorder = (function () {
        function Reorder(parent) {
            ej2_grids_1.Grid.Inject(ej2_grids_1.Reorder);
            this.parent = parent;
            this.addEventListener();
        }
        Reorder.prototype.getModuleName = function () {
            return 'reorder';
        };
        Reorder.prototype.addEventListener = function () {
            this.parent.on('getColumnIndex', this.getTreeColumn, this);
        };
        Reorder.prototype.removeEventListener = function () {
            if (this.parent.isDestroyed) {
                return;
            }
            this.parent.off('getColumnIndex', this.getTreeColumn);
        };
        Reorder.prototype.destroy = function () {
            this.removeEventListener();
        };
        Reorder.prototype.getTreeColumn = function () {
            var columnModel = 'columnModel';
            var treeColumn = this.parent["" + columnModel][this.parent.treeColumnIndex];
            var treeIndex;
            var updatedCols = this.parent.getColumns();
            for (var f = 0; f < updatedCols.length; f++) {
                var treeColumnfield = ej2_grids_1.getObject('field', treeColumn);
                var parentColumnfield = ej2_grids_1.getObject('field', updatedCols[parseInt(f.toString(), 10)]);
                if (treeColumnfield === parentColumnfield) {
                    treeIndex = f;
                    break;
                }
            }
            this.parent.setProperties({ treeColumnIndex: treeIndex }, true);
        };
        return Reorder;
    }());
    exports.Reorder = Reorder;
});