Upgrade to ExtJS 4.0.1 - Released 05/18/2011
[extjs.git] / docs / source / LockingView.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5   <title>The source code</title>
6   <link href="../prettify/prettify.css" type="text/css" rel="stylesheet" />
7   <script type="text/javascript" src="../prettify/prettify.js"></script>
8   <style type="text/css">
9     .highlight { display: block; background-color: #ddd; }
10   </style>
11   <script type="text/javascript">
12     function highlight() {
13       document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
14     }
15   </script>
16 </head>
17 <body onload="prettyPrint(); highlight();">
18   <pre class="prettyprint lang-js"><span id='Ext-grid-LockingView'>/**
19 </span> * @class Ext.grid.LockingView
20  * This class is used internally to provide a single interface when using
21  * a locking grid. Internally, the locking grid creates 2 separate grids,
22  * so this class is used to map calls appropriately.
23  * @ignore
24  */
25 Ext.define('Ext.grid.LockingView', {
26     
27     mixins: {
28         observable: 'Ext.util.Observable'
29     },
30     
31     eventRelayRe: /^(beforeitem|beforecontainer|item|container|cell)/,
32     
33     constructor: function(config){
34         var me = this,
35             eventNames = [],
36             eventRe = me.eventRelayRe,
37             locked = config.locked.getView(),
38             normal = config.normal.getView(),
39             events,
40             event;
41         
42         Ext.apply(me, {
43             lockedView: locked,
44             normalView: normal,
45             lockedGrid: config.locked,
46             normalGrid: config.normal,
47             panel: config.panel
48         });
49         me.mixins.observable.constructor.call(me, config);
50         
51         // relay events
52         events = locked.events;
53         for (event in events) {
54             if (events.hasOwnProperty(event) &amp;&amp; eventRe.test(event)) {
55                 eventNames.push(event);
56             }
57         }
58         me.relayEvents(locked, eventNames);
59         me.relayEvents(normal, eventNames);
60         
61         normal.on({
62             scope: me,
63             itemmouseleave: me.onItemMouseLeave,
64             itemmouseenter: me.onItemMouseEnter
65         });
66         
67         locked.on({
68             scope: me,
69             itemmouseleave: me.onItemMouseLeave,
70             itemmouseenter: me.onItemMouseEnter
71         });
72     },
73     
74     getGridColumns: function() {
75         var cols = this.lockedGrid.headerCt.getGridColumns();
76         return cols.concat(this.normalGrid.headerCt.getGridColumns());
77     },
78     
79     onItemMouseEnter: function(view, record){
80         var me = this,
81             locked = me.lockedView,
82             other = me.normalView,
83             item;
84             
85         if (view.trackOver) {
86             if (view !== locked) {
87                 other = locked;
88             }
89             item = other.getNode(record);
90             other.highlightItem(item);
91         }
92     },
93     
94     onItemMouseLeave: function(view, record){
95         var me = this,
96             locked = me.lockedView,
97             other = me.normalView;
98             
99         if (view.trackOver) {
100             if (view !== locked) {
101                 other = locked;
102             }
103             other.clearHighlight();
104         }
105     },
106     
107     relayFn: function(name, args){
108         args = args || [];
109         
110         var view = this.lockedView;
111         view[name].apply(view, args || []);    
112         view = this.normalView;
113         view[name].apply(view, args || []);   
114     },
115     
116     getSelectionModel: function(){
117         return this.panel.getSelectionModel();    
118     },
119     
120     getStore: function(){
121         return this.panel.store;
122     },
123     
124     getNode: function(nodeInfo){
125         // default to the normal view
126         return this.normalView.getNode(nodeInfo);
127     },
128     
129     getCell: function(record, column){
130         var view = this.lockedView,
131             row;
132         
133         
134         if (view.getHeaderAtIndex(column) === -1) {
135             view = this.normalView;
136         }
137         
138         row = view.getNode(record);
139         return Ext.fly(row).down(column.getCellSelector());
140     },
141     
142     getRecord: function(node){
143         var result = this.lockedView.getRecord(node);
144         if (!node) {
145             result = this.normalView.getRecord(node);
146         }
147         return result;
148     },
149     
150     addElListener: function(eventName, fn, scope){
151         this.relayFn('addElListener', arguments);
152     },
153     
154     refreshNode: function(){
155         this.relayFn('refreshNode', arguments);
156     },
157     
158     refresh: function(){
159         this.relayFn('refresh', arguments);
160     },
161     
162     bindStore: function(){
163         this.relayFn('bindStore', arguments);
164     },
165     
166     addRowCls: function(){
167         this.relayFn('addRowCls', arguments);
168     },
169     
170     removeRowCls: function(){
171         this.relayFn('removeRowCls', arguments);
172     }
173        
174 });</pre>
175 </body>
176 </html>