Upgrade to ExtJS 3.1.1 - Released 02/08/2010
[extjs.git] / src / widgets / form / DisplayField.js
1 /*!
2  * Ext JS Library 3.1.1
3  * Copyright(c) 2006-2010 Ext JS, LLC
4  * licensing@extjs.com
5  * http://www.extjs.com/license
6  */
7 /**\r
8  * @class Ext.form.DisplayField\r
9  * @extends Ext.form.Field\r
10  * A display-only text field which is not validated and not submitted.\r
11  * @constructor\r
12  * Creates a new DisplayField.\r
13  * @param {Object} config Configuration options\r
14  * @xtype displayfield\r
15  */\r
16 Ext.form.DisplayField = Ext.extend(Ext.form.Field,  {\r
17     validationEvent : false,\r
18     validateOnBlur : false,\r
19     defaultAutoCreate : {tag: "div"},\r
20     /**\r
21      * @cfg {String} fieldClass The default CSS class for the field (defaults to <tt>"x-form-display-field"</tt>)\r
22      */\r
23     fieldClass : "x-form-display-field",\r
24     /**\r
25      * @cfg {Boolean} htmlEncode <tt>false</tt> to skip HTML-encoding the text when rendering it (defaults to\r
26      * <tt>false</tt>). This might be useful if you want to include tags in the field's innerHTML rather than\r
27      * rendering them as string literals per the default logic.\r
28      */\r
29     htmlEncode: false,\r
30 \r
31     // private\r
32     initEvents : Ext.emptyFn,\r
33 \r
34     isValid : function(){\r
35         return true;\r
36     },\r
37 \r
38     validate : function(){\r
39         return true;\r
40     },\r
41 \r
42     getRawValue : function(){\r
43         var v = this.rendered ? this.el.dom.innerHTML : Ext.value(this.value, '');\r
44         if(v === this.emptyText){\r
45             v = '';\r
46         }\r
47         if(this.htmlEncode){\r
48             v = Ext.util.Format.htmlDecode(v);\r
49         }\r
50         return v;\r
51     },\r
52 \r
53     getValue : function(){\r
54         return this.getRawValue();\r
55     },\r
56     \r
57     getName: function() {\r
58         return this.name;\r
59     },\r
60 \r
61     setRawValue : function(v){\r
62         if(this.htmlEncode){\r
63             v = Ext.util.Format.htmlEncode(v);\r
64         }\r
65         return this.rendered ? (this.el.dom.innerHTML = (Ext.isEmpty(v) ? '' : v)) : (this.value = v);\r
66     },\r
67 \r
68     setValue : function(v){\r
69         this.setRawValue(v);\r
70         return this;\r
71     }\r
72     /** \r
73      * @cfg {String} inputType \r
74      * @hide\r
75      */\r
76     /** \r
77      * @cfg {Boolean} disabled \r
78      * @hide\r
79      */\r
80     /** \r
81      * @cfg {Boolean} readOnly \r
82      * @hide\r
83      */\r
84     /** \r
85      * @cfg {Boolean} validateOnBlur \r
86      * @hide\r
87      */\r
88     /** \r
89      * @cfg {Number} validationDelay \r
90      * @hide\r
91      */\r
92     /** \r
93      * @cfg {String/Boolean} validationEvent \r
94      * @hide\r
95      */\r
96 });\r
97 \r
98 Ext.reg('displayfield', Ext.form.DisplayField);\r