LockingView.html
4.87 KB
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
<!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-LockingView'>/**
</span> * This class is used internally to provide a single interface when using
* a locking grid. Internally, the locking grid creates two separate grids,
* so this class is used to map calls appropriately.
* @private
*/
Ext.define('Ext.grid.LockingView', {
mixins: {
observable: 'Ext.util.Observable'
},
eventRelayRe: /^(beforeitem|beforecontainer|item|container|cell)/,
constructor: function(config){
var me = this,
eventNames = [],
eventRe = me.eventRelayRe,
locked = config.locked.getView(),
normal = config.normal.getView(),
events,
event;
Ext.apply(me, {
lockedView: locked,
normalView: normal,
lockedGrid: config.locked,
normalGrid: config.normal,
panel: config.panel
});
me.mixins.observable.constructor.call(me, config);
// relay events
events = locked.events;
for (event in events) {
if (events.hasOwnProperty(event) && eventRe.test(event)) {
eventNames.push(event);
}
}
me.relayEvents(locked, eventNames);
me.relayEvents(normal, eventNames);
normal.on({
scope: me,
itemmouseleave: me.onItemMouseLeave,
itemmouseenter: me.onItemMouseEnter
});
locked.on({
scope: me,
itemmouseleave: me.onItemMouseLeave,
itemmouseenter: me.onItemMouseEnter
});
},
getGridColumns: function() {
var cols = this.lockedGrid.headerCt.getGridColumns();
return cols.concat(this.normalGrid.headerCt.getGridColumns());
},
getEl: function(column){
return this.getViewForColumn(column).getEl();
},
getViewForColumn: function(column) {
var view = this.lockedView,
inLocked;
view.headerCt.cascade(function(col){
if (col === column) {
inLocked = true;
return false;
}
});
return inLocked ? view : this.normalView;
},
onItemMouseEnter: function(view, record){
var me = this,
locked = me.lockedView,
other = me.normalView,
item;
if (view.trackOver) {
if (view !== locked) {
other = locked;
}
item = other.getNode(record);
other.highlightItem(item);
}
},
onItemMouseLeave: function(view, record){
var me = this,
locked = me.lockedView,
other = me.normalView;
if (view.trackOver) {
if (view !== locked) {
other = locked;
}
other.clearHighlight();
}
},
relayFn: function(name, args){
args = args || [];
var view = this.lockedView;
view[name].apply(view, args || []);
view = this.normalView;
view[name].apply(view, args || []);
},
getSelectionModel: function(){
return this.panel.getSelectionModel();
},
getStore: function(){
return this.panel.store;
},
getNode: function(nodeInfo){
// default to the normal view
return this.normalView.getNode(nodeInfo);
},
getCell: function(record, column){
var view = this.getViewForColumn(column),
row;
row = view.getNode(record);
return Ext.fly(row).down(column.getCellSelector());
},
getRecord: function(node){
var result = this.lockedView.getRecord(node);
if (!node) {
result = this.normalView.getRecord(node);
}
return result;
},
addElListener: function(eventName, fn, scope){
this.relayFn('addElListener', arguments);
},
refreshNode: function(){
this.relayFn('refreshNode', arguments);
},
refresh: function(){
this.relayFn('refresh', arguments);
},
bindStore: function(){
this.relayFn('bindStore', arguments);
},
addRowCls: function(){
this.relayFn('addRowCls', arguments);
},
removeRowCls: function(){
this.relayFn('removeRowCls', arguments);
}
});</pre>
</body>
</html>