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, {
34 * @cfg {String} focusClass The CSS class to use when the checkbox receives focus (defaults to undefined)
36 focusClass : undefined,
38 * @cfg {String} fieldClass The default CSS class for the checkbox (defaults to "x-form-field")
40 fieldClass: 'x-form-field',
43 * @cfg {Function} valueRenderer The renderer for the field (so you can reformat output). should return raw HTML
45 valueRenderer: undefined,
49 * @cfg {String/Object} autoCreate A DomHelper element spec, or true for a default element spec (defaults to
50 * {tag: "input", type: "checkbox", autocomplete: "off"})
53 // 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);
67 getResizeEl : function(){
71 getPositionEl : function(){
76 onRender : function(ct, position){
77 console.log('DisplayField onRender');
78 Roo.form.DisplayField.superclass.onRender.call(this, ct, position);
79 //if(this.inputValue !== undefined){
82 this.wrap = this.el.wrap();
83 console.log(this.wrap);
84 this.viewEl = this.wrap.createChild({ tag: 'div'});
87 this.viewEl.applyStyles(this.bodyStyle);
89 //this.viewEl.setStyle('padding', '2px');
91 this.setValue(this.value);
96 initValue : Roo.emptyFn,
101 onClick : function(){
106 * Sets the checked state of the checkbox.
107 * @param {Boolean/String} checked True, 'true', '1', or 'on' to check the checkbox, any other value will uncheck it.
109 setValue : function(v){
111 var html = this.valueRenderer ? this.valueRenderer(v) : String.format('{0}', v);
112 this.viewEl.dom.innerHTML = html;
113 Roo.form.DisplayField.superclass.setValue.call(this, v);