Upgrade to ExtJS 4.0.7 - Released 10/19/2011
[extjs.git] / src / grid / LockingView.js
index e117f3c..22bd49e 100644 (file)
@@ -1,18 +1,32 @@
+/*
+
+This file is part of Ext JS 4
+
+Copyright (c) 2011 Sencha Inc
+
+Contact:  http://www.sencha.com/contact
+
+GNU General Public License Usage
+This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file.  Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
+
+If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
+
+*/
 /**
  * @class Ext.grid.LockingView
  * This class is used internally to provide a single interface when using
- * a locking grid. Internally, the locking grid creates 2 separate grids,
+ * a locking grid. Internally, the locking grid creates two separate grids,
  * so this class is used to map calls appropriately.
  * @ignore
  */
 Ext.define('Ext.grid.LockingView', {
-    
+
     mixins: {
         observable: 'Ext.util.Observable'
     },
-    
+
     eventRelayRe: /^(beforeitem|beforecontainer|item|container|cell)/,
-    
+
     constructor: function(config){
         var me = this,
             eventNames = [],
@@ -21,7 +35,7 @@ Ext.define('Ext.grid.LockingView', {
             normal = config.normal.getView(),
             events,
             event;
-        
+
         Ext.apply(me, {
             lockedView: locked,
             normalView: normal,
@@ -30,7 +44,7 @@ Ext.define('Ext.grid.LockingView', {
             panel: config.panel
         });
         me.mixins.observable.constructor.call(me, config);
-        
+
         // relay events
         events = locked.events;
         for (event in events) {
@@ -40,31 +54,49 @@ Ext.define('Ext.grid.LockingView', {
         }
         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;
@@ -73,12 +105,12 @@ Ext.define('Ext.grid.LockingView', {
             other.highlightItem(item);
         }
     },
-    
+
     onItemMouseLeave: function(view, record){
         var me = this,
             locked = me.lockedView,
             other = me.normalView;
-            
+
         if (view.trackOver) {
             if (view !== locked) {
                 other = locked;
@@ -86,42 +118,37 @@ Ext.define('Ext.grid.LockingView', {
             other.clearHighlight();
         }
     },
-    
+
     relayFn: function(name, args){
         args = args || [];
-        
+
         var view = this.lockedView;
-        view[name].apply(view, args || []);    
+        view[name].apply(view, args || []);
         view = this.normalView;
-        view[name].apply(view, args || []);   
+        view[name].apply(view, args || []);
     },
-    
+
     getSelectionModel: function(){
-        return this.panel.getSelectionModel();    
+        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.lockedView,
+        var view = this.getViewForColumn(column),
             row;
-        
-        
-        if (view.getHeaderAtIndex(column) === -1) {
-            view = this.normalView;
-        }
-        
+
         row = view.getNode(record);
         return Ext.fly(row).down(column.getCellSelector());
     },
-    
+
     getRecord: function(node){
         var result = this.lockedView.getRecord(node);
         if (!node) {
@@ -129,25 +156,29 @@ Ext.define('Ext.grid.LockingView', {
         }
         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);
     }
-       
-});
\ No newline at end of file
+
+});