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.
16 * Creates a new Display Field item.
17 * @param {Object} config Configuration options
19 Roo.form.DisplayField = function(config){
20 Roo.form.DisplayField.superclass.constructor.call(this, config);
24 Roo.extend(Roo.form.DisplayField, Roo.form.TextField, {
31 * @cfg {String} focusClass The CSS class to use when the checkbox receives focus (defaults to undefined)
33 focusClass : undefined,
35 * @cfg {String} fieldClass The default CSS class for the checkbox (defaults to "x-form-field")
37 fieldClass: 'x-form-field',
40 * @cfg {Function} valueRenderer The renderer for the field (so you can reformat output). should return raw HTML
42 valueRenderer: undefined,
46 * @cfg {String/Object} autoCreate A DomHelper element spec, or true for a default element spec (defaults to
47 * {tag: "input", type: "checkbox", autocomplete: "off"})
50 // defaultAutoCreate : { tag: 'input', type: 'hidden', autocomplete: 'off'},
52 onResize : function(){
53 Roo.form.DisplayField.superclass.onResize.apply(this, arguments);
57 initEvents : function(){
58 // Roo.form.Checkbox.superclass.initEvents.call(this);
64 getResizeEl : function(){
68 getPositionEl : function(){
73 onRender : function(ct, position){
75 Roo.form.DisplayField.superclass.onRender.call(this, ct, position);
76 //if(this.inputValue !== undefined){
77 this.wrap = this.el.wrap();
79 this.viewEl = this.wrap.createChild({ tag: 'div', cls: 'x-form-displayfield'});
82 this.viewEl.applyStyles(this.bodyStyle);
84 //this.viewEl.setStyle('padding', '2px');
86 this.setValue(this.value);
91 initValue : Roo.emptyFn,
101 * Sets the checked state of the checkbox.
102 * @param {Boolean/String} checked True, 'true', '1', or 'on' to check the checkbox, any other value will uncheck it.
104 setValue : function(v){
106 var html = this.valueRenderer ? this.valueRenderer(v) : String.format('{0}', v);
107 // this might be called before we have a dom element..
111 this.viewEl.dom.innerHTML = html;
112 Roo.form.DisplayField.superclass.setValue.call(this, v);