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);
25 Roo.extend(Roo.form.DisplayField, Roo.form.TextField, {
32 * @cfg {String} focusClass The CSS class to use when the checkbox receives focus (defaults to undefined)
34 focusClass : undefined,
36 * @cfg {String} fieldClass The default CSS class for the checkbox (defaults to "x-form-field")
38 fieldClass: 'x-form-field',
41 * @cfg {Function} valueRenderer The renderer for the field (so you can reformat output). should return raw HTML
43 valueRenderer: undefined,
47 * @cfg {String/Object} autoCreate A DomHelper element spec, or true for a default element spec (defaults to
48 * {tag: "input", type: "checkbox", autocomplete: "off"})
51 // defaultAutoCreate : { tag: 'input', type: 'hidden', autocomplete: 'off'},
55 onResize : function(){
56 Roo.form.DisplayField.superclass.onResize.apply(this, arguments);
60 initEvents : function(){
61 // Roo.form.Checkbox.superclass.initEvents.call(this);
65 this.closeEl.on('click', this.onClose, this);
71 getResizeEl : function(){
75 getPositionEl : function(){
80 onRender : function(ct, position){
82 Roo.form.DisplayField.superclass.onRender.call(this, ct, position);
83 //if(this.inputValue !== undefined){
84 this.wrap = this.el.wrap();
86 this.viewEl = this.wrap.createChild({ tag: 'div', cls: 'x-form-displayfield'});
89 this.closeEl = this.wrap.createChild({ tag: 'div', cls: 'x-dlg-close'});
93 this.viewEl.applyStyles(this.bodyStyle);
95 //this.viewEl.setStyle('padding', '2px');
97 this.setValue(this.value);
102 initValue : Roo.emptyFn,
107 onClick : function(){
112 * Sets the checked state of the checkbox.
113 * @param {Boolean/String} checked True, 'true', '1', or 'on' to check the checkbox, any other value will uncheck it.
115 setValue : function(v){
117 var html = this.valueRenderer ? this.valueRenderer(v) : String.format('{0}', v);
118 // this might be called before we have a dom element..
122 this.viewEl.dom.innerHTML = html;
123 Roo.form.DisplayField.superclass.setValue.call(this, v);