4 * Copyright(c) 2006-2007, Ext JS, LLC.
6 * Originally Released Under LGPL - original licence link has changed is not relivant.
9 * <script type="text/javascript">
12 * @class Roo.form.DisplayField
13 * @extends Roo.form.Field
14 * A generic Field to display non-editable data.
15 * @cfg {Boolean} closable (true|false) default false
17 * Creates a new Display Field item.
18 * @param {Object} config Configuration options
20 Roo.form.DisplayField = function(config){
21 Roo.form.DisplayField.superclass.constructor.call(this, config);
26 * Fires after the click the close btn
27 * @param {Roo.form.DisplayField} this
33 Roo.extend(Roo.form.DisplayField, Roo.form.TextField, {
40 * @cfg {String} focusClass The CSS class to use when the checkbox receives focus (defaults to undefined)
42 focusClass : undefined,
44 * @cfg {String} fieldClass The default CSS class for the checkbox (defaults to "x-form-field")
46 fieldClass: 'x-form-field',
49 * @cfg {Function} valueRenderer The renderer for the field (so you can reformat output). should return raw HTML
51 valueRenderer: undefined,
55 * @cfg {String/Object} autoCreate A DomHelper element spec, or true for a default element spec (defaults to
56 * {tag: "input", type: "checkbox", autocomplete: "off"})
59 // defaultAutoCreate : { tag: 'input', type: 'hidden', autocomplete: 'off'},
63 onResize : function(){
64 Roo.form.DisplayField.superclass.onResize.apply(this, arguments);
68 initEvents : function(){
69 // Roo.form.Checkbox.superclass.initEvents.call(this);
73 this.closeEl.on('click', this.onClose, this);
79 getResizeEl : function(){
83 getPositionEl : function(){
88 onRender : function(ct, position){
90 Roo.form.DisplayField.superclass.onRender.call(this, ct, position);
91 //if(this.inputValue !== undefined){
92 this.wrap = this.el.wrap();
94 this.viewEl = this.wrap.createChild({ tag: 'div', cls: 'x-form-displayfield'});
97 this.closeEl = this.wrap.createChild({ tag: 'div', cls: 'x-dlg-close'});
100 if (this.bodyStyle) {
101 this.viewEl.applyStyles(this.bodyStyle);
103 //this.viewEl.setStyle('padding', '2px');
105 this.setValue(this.value);
110 initValue : Roo.emptyFn,
115 onClick : function(){
120 * Sets the checked state of the checkbox.
121 * @param {Boolean/String} checked True, 'true', '1', or 'on' to check the checkbox, any other value will uncheck it.
123 setValue : function(v){
125 var html = this.valueRenderer ? this.valueRenderer(v) : String.format('{0}', v);
126 // this might be called before we have a dom element..
130 this.viewEl.dom.innerHTML = html;
131 Roo.form.DisplayField.superclass.setValue.call(this, v);
135 onClose : function(e)
139 this.fireEvent('close', this);