X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/0494b8d9b9bb03ab6c22b34dae81261e3cd7e3e6..7a654f8d43fdb43d78b63d90528bed6e86b608cc:/src/form/field/Display.js diff --git a/src/form/field/Display.js b/src/form/field/Display.js new file mode 100644 index 00000000..669edf45 --- /dev/null +++ b/src/form/field/Display.js @@ -0,0 +1,124 @@ +/** + * @class Ext.form.field.Display + * @extends Ext.form.field.Base + *

A display-only text field which is not validated and not submitted. This is useful for when you want + * to display a value from a form's {@link Ext.form.Basic#load loaded data} but do not want to allow the + * user to edit or submit that value. The value can be optionally {@link #htmlEncode HTML encoded} if it contains + * HTML markup that you do not want to be rendered.

+ *

If you have more complex content, or need to include components within the displayed content, also + * consider using a {@link Ext.form.FieldContainer} instead.

+ * {@img Ext.form.Display/Ext.form.Display.png Ext.form.Display component} + *

Example:

+ *

+    Ext.create('Ext.form.Panel', {
+        width: 175,
+        height: 120,
+        bodyPadding: 10,
+        title: 'Final Score',
+        items: [{
+            xtype: 'displayfield',
+            fieldLabel: 'Home',
+            name: 'home_score',
+            value: '10'
+        }, {
+            xtype: 'displayfield',
+            fieldLabel: 'Visitor',
+            name: 'visitor_score',
+            value: '11'
+        }],
+        buttons: [{
+            text: 'Update',
+        }],
+        renderTo: Ext.getBody()
+    });
+
+ + * @constructor + * Creates a new DisplayField. + * @param {Object} config Configuration options + * + * @xtype displayfield + */ +Ext.define('Ext.form.field.Display', { + extend:'Ext.form.field.Base', + alias: 'widget.displayfield', + requires: ['Ext.util.Format', 'Ext.XTemplate'], + alternateClassName: ['Ext.form.DisplayField', 'Ext.form.Display'], + fieldSubTpl: [ + '
', + { + compiled: true, + disableFormats: true + } + ], + + /** + * @cfg {String} fieldCls The default CSS class for the field (defaults to "x-form-display-field") + */ + fieldCls: Ext.baseCSSPrefix + 'form-display-field', + + /** + * @cfg {Boolean} htmlEncode false to skip HTML-encoding the text when rendering it (defaults to + * false). This might be useful if you want to include tags in the field's innerHTML rather than + * rendering them as string literals per the default logic. + */ + htmlEncode: false, + + validateOnChange: false, + + initEvents: Ext.emptyFn, + + submitValue: false, + + isValid: function() { + return true; + }, + + validate: function() { + return true; + }, + + getRawValue: function() { + return this.rawValue; + }, + + setRawValue: function(value) { + var me = this; + value = Ext.value(value, ''); + me.rawValue = value; + if (me.rendered) { + me.inputEl.dom.innerHTML = me.htmlEncode ? Ext.util.Format.htmlEncode(value) : value; + } + return value; + }, + + // private + getContentTarget: function() { + return this.inputEl; + } + + /** + * @cfg {String} inputType + * @hide + */ + /** + * @cfg {Boolean} disabled + * @hide + */ + /** + * @cfg {Boolean} readOnly + * @hide + */ + /** + * @cfg {Boolean} validateOnChange + * @hide + */ + /** + * @cfg {Number} checkChangeEvents + * @hide + */ + /** + * @cfg {Number} checkChangeBuffer + * @hide + */ +});