1. #1
    Ext User
    Join Date
    Aug 2007
    Posts
    21
    Vote Rating
    0
    bai is on a distinguished road

      0  

    Default dynamic form - help

    dynamic form - help


    I am trying to build a form dynamically which has some fieldsets. But when I try to render the form, resultForm.render(document.body); gives me error, 'OwnerCt.labelAlign is null or not an object'. I tried setting the labelAlign property, but it did not help. Can anyone help to fix this.

    Below is the code snippet.
    Code:
    var resultForm = new Ext.FormPanel({
            id:'resultForm',
    		frame:true,
            bodyStyle:'padding:5px 5px 0',
            width: 1240,
            items: [{
                layout:'column',
    			labelWidth:125,
                items:[{
                    columnWidth:.33,
                    layout: 'form',
                    items: [{
    				}]
                }
                ]
            }]
    });
    for(var j = 0; j < resultFieldSets.length; j++) {
    		fieldSet = new Ext.form.FieldSet({
    			title: resultFieldSets[j],
    			id: 'fs'+j,
    			labelAlign:'right',
    			items: [
    				{  }
    			]
    		});
    
    		fsObj = Ext.getCmp('fs'+j);
    
    		for(var i = 0; i < resultFormLabel.length; i++) {
    			if(resultFormType[i] == 'textfield')
    			{
    				resultItem = new Ext.form.TextField({        
    								fieldLabel: resultFormLabel[i],
    								name: resultFormLabel[i],
    								id: resultFormLabel[i],
    								xtype: resultFormType[i],
    								value: resultFormData[i]
    							});
    			}
    			fsObj.items.add(resultItem); 
    		}
    		resultForm.items.add(fsObj);
    	}
    	resultForm.render(document.body);

  2. #2
    Sencha User
    Join Date
    Mar 2007
    Posts
    10
    Vote Rating
    0
    nproto is on a distinguished road

      0  

    Default


    I think that when you explicitly render the form you have to use an existing el in the configuration.

  3. #3
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,507
    Vote Rating
    56
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    That's an Ext 2 class, are you actually using Ext 2?

  4. #4
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,507
    Vote Rating
    56
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    Well, you must be, but just posting in the wrong forum.

    Anyway, just embedd everything in the FormPanel's items property.

    Don't give it an empty items Array, and then add stuff, just create the whole thing in one shot.

    If you need to create the items object dynamically, then do it before, and just pass the result into the FormPanel constructor.

Thread Participants: 2