13693261870
2022-09-16 354b3dbfbffb3df45212a2a44dbbf48b4acc2594
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>The source code</title>
  <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  <style type="text/css">
    .highlight { display: block; background-color: #ddd; }
  </style>
  <script type="text/javascript">
    function highlight() {
      document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
    }
  </script>
</head>
<body onload="prettyPrint(); highlight();">
  <pre class="prettyprint lang-js"><span id='Ext-grid-ColumnManager'>/**
</span> * @private
 *
 * Manages and provides information about a TablePanel's *visible leaf* columns.
 */
Ext.define('Ext.grid.ColumnManager', {
    alternateClassName: ['Ext.grid.ColumnModel'],
 
<span id='Ext-grid-ColumnManager-property-columns'>    columns: null,
</span>
<span id='Ext-grid-ColumnManager-method-constructor'>    constructor: function(headerCt, secondHeaderCt) {
</span>        //&lt;debug&gt;
        if (!headerCt.isRootHeader) {
            Ext.Error.raise('ColumnManager must be passed an instantiated HeaderContainer');
        }
        //&lt;/debug&gt;
        this.headerCt = headerCt;
 
        // We are managing columns for a lockable grid...
        if (secondHeaderCt) {
            //&lt;debug&gt;
            if (!headerCt.isRootHeader) {
                Ext.Error.raise('ColumnManager must be passed an instantiated HeaderContainer');
            }
            //&lt;/debug&gt;
            this.secondHeaderCt = secondHeaderCt;
        }
    },
 
<span id='Ext-grid-ColumnManager-method-getColumns'>    getColumns: function() {
</span>        if (!this.columns) {
            this.cacheColumns();
        }
        return this.columns;
    },
 
<span id='Ext-grid-ColumnManager-method-getHeaderIndex'>    /**
</span>     * Returns the index of a leaf level header regardless of what the nesting
     * structure is.
     *
     * If a group header is passed, the index of the first leaf level heder within it is returned.
     *
     * @param {Ext.grid.column.Column} header The header to find the index of
     * @return {Number} The index of the specified column header
     */
    getHeaderIndex: function(header) {
        // If we are being asked the index of a group header, find the first leaf header node, and return the index of that
        if (header.isGroupHeader) {
            header = header.down(':not([isGroupHeader])');
        }
        return Ext.Array.indexOf(this.getColumns(), header);
    },
 
<span id='Ext-grid-ColumnManager-method-getHeaderAtIndex'>    /**
</span>     * Get a leaf level header by index regardless of what the nesting
     * structure is.
     * @param {Number} index The column index for which to retrieve the column.
     * @return {Ext.grid.column.Column} The header. `null` if it doesn't exist.
     */
    getHeaderAtIndex: function(index) {
        var columns = this.getColumns();
        return columns.length ? columns[index] : null;
    },
    
<span id='Ext-grid-ColumnManager-method-getHeaderById'>    /**
</span>     * Get a leaf level header by index regardless of what the nesting
     * structure is.
     * @param {String} id The id
     * @return {Ext.grid.column.Column} The header. `null` if it doesn't exist.
     */
    getHeaderById: function(id) {
        var columns = this.getColumns(),
            len = columns.length,
            i, header;
            
        for (i = 0; i &lt; len; ++i) {
            header = columns[i];
            if (header.getItemId() === id) {
                return header;
            }
        }
        return null;
    },
 
<span id='Ext-grid-ColumnManager-method-getVisibleHeaderClosestToIndex'>    /**
</span>     * When passed a column index, returns the closet *visible* column to that. If the column at the passed index is visible,
     * that is returned. If it is hidden, either the next visible, or the previous visible column is returned.
     * @param {Number} index Position at which to find the closest visible column.
     */
    getVisibleHeaderClosestToIndex: function(index) {
        var result = this.getHeaderAtIndex(index);
        if (result &amp;&amp; result.hidden) {
            result = result.next(':not([hidden])') || result.prev(':not([hidden])');
        }
        return result;
    },
 
<span id='Ext-grid-ColumnManager-method-cacheColumns'>    cacheColumns: function() {
</span>        this.columns = this.headerCt.getVisibleGridColumns();
        if (this.secondHeaderCt) {
            Ext.Array.push(this.columns, this.secondHeaderCt.getVisibleGridColumns());
        }
    },
 
<span id='Ext-grid-ColumnManager-method-invalidate'>    invalidate: function() {
</span>        this.columns = null;
 
        // If we are part of a lockable assembly, invalidate the root column manager
        if (this.rootColumns) {
            this.rootColumns.invalidate();
        }
    }
}, function() {
    this.createAlias('indexOf', 'getHeaderIndex');
});</pre>
</body>
</html>