Upgrade to ExtJS 4.0.0 - Released 04/26/2011
[extjs.git] / src / grid / CellEditor.js
1 /**
2  * @class Ext.grid.CellEditor
3  * @extends Ext.Editor
4  * Internal utility class that provides default configuration for cell editing.
5  * @ignore
6  */
7 Ext.define('Ext.grid.CellEditor', {
8     extend: 'Ext.Editor',
9     constructor: function(config) {
10         if (config.field) {
11             config.field.monitorTab = false;
12         }
13         config.autoSize = {
14             width: 'boundEl'
15         };
16         this.callParent(arguments);
17     },
18     
19     /**
20      * @private
21      * Hide the grid cell when editor is shown.
22      */
23     onShow: function() {
24         var first = this.boundEl.first();
25         if (first) {
26             first.hide();
27         }
28         this.callParent(arguments);
29     },
30     
31     /**
32      * @private
33      * Show grid cell when editor is hidden.
34      */
35     onHide: function() {
36         var first = this.boundEl.first();
37         if (first) {
38             first.show();
39         }
40         this.callParent(arguments);
41     },
42     
43     /**
44      * @private
45      * Fix checkbox blur when it is clicked.
46      */
47     afterRender: function() {
48         this.callParent(arguments);
49         var field = this.field;
50         if (field.isXType('checkboxfield')) {
51             field.mon(field.inputEl, 'mousedown', this.onCheckBoxMouseDown, this);
52             field.mon(field.inputEl, 'click', this.onCheckBoxClick, this);
53         }
54     },
55     
56     /**
57      * @private
58      * Because when checkbox is clicked it loses focus  completeEdit is bypassed.
59      */
60     onCheckBoxMouseDown: function() {
61         this.completeEdit = Ext.emptyFn;
62     },
63     
64     /**
65      * @private
66      * Restore checkbox focus and completeEdit method.
67      */
68     onCheckBoxClick: function() {
69         delete this.completeEdit;
70         this.field.focus(false, 10);
71     },
72     
73     alignment: "tl-tl",
74     hideEl : false,
75     cls: Ext.baseCSSPrefix + "small-editor " + Ext.baseCSSPrefix + "grid-editor",
76     shim: false,
77     shadow: false
78 });