Fix #7197 - fix form layout files and doc labelalign
[roojs1] / Roo / form / Row.js
1
2 /**
3  * @class Roo.form.Row
4  * @extends Roo.form.Layout
5  * @children Roo.form.Column Roo.form.Row Roo.form.Field Roo.Button Roo.form.TextItem Roo.form.FieldSet
6  * Creates a row container for layout and rendering of fields in an {@link Roo.form.Form}.
7  * @constructor
8  * @param {Object} config Configuration options
9  */
10
11  
12 Roo.form.Row = function(config){
13     Roo.form.Row.superclass.constructor.call(this, config);
14 };
15  
16 Roo.extend(Roo.form.Row, Roo.form.Layout, {
17       /**
18      * @cfg {Number/String} width
19      * The fixed width of the column in pixels or CSS value (defaults to "auto")
20      */
21     /**
22      * @cfg {Number/String} height
23      * The fixed height of the column in pixels or CSS value (defaults to "auto")
24      */
25     defaultAutoCreate : {tag: 'div', cls: 'x-form-ct x-form-row'},
26     
27     padWidth : 20,
28     // private
29     onRender : function(ct, position){
30         //console.log('row render');
31         if(!this.rowTpl){
32             var t = new Roo.Template(
33                 '<div class="x-form-item {5}" style="float:left;width:{6}px">',
34                     '<label for="{0}" style="{2}">{1}{4}</label>',
35                     '<div class="x-form-element" id="x-form-el-{0}" style="{3}">',
36                     '</div>',
37                 '</div>'
38             );
39             t.disableFormats = true;
40             t.compile();
41             Roo.form.Layout.prototype.rowTpl = t;
42         }
43         this.fieldTpl = this.rowTpl;
44         
45         //console.log('lw' + this.labelWidth +', la:' + this.labelAlign);
46         var labelWidth = 100;
47         
48         if ((this.labelAlign != 'top')) {
49             if (typeof this.labelWidth == 'number') {
50                 labelWidth = this.labelWidth
51             }
52             this.padWidth =  20 + labelWidth;
53             
54         }
55         
56         Roo.form.Column.superclass.onRender.call(this, ct, position);
57         if(this.width){
58             this.el.setWidth(this.width);
59         }
60         if(this.height){
61             this.el.setHeight(this.height);
62         }
63     },
64     
65     // private
66     renderField : function(f){
67         f.fieldEl = this.fieldTpl.append(this.el, [
68                f.id, f.fieldLabel,
69                f.labelStyle||this.labelStyle||'',
70                this.elementStyle||'',
71                typeof f.labelSeparator == 'undefined' ? this.labelSeparator : f.labelSeparator,
72                f.itemCls||this.itemCls||'',
73                f.width ? f.width + this.padWidth : 160 + this.padWidth
74        ],true);
75     }
76 });
77