How to get custom input value from text box of window window?

I have a webpage with buttons developed in Extjs. When a user clicks on one of these buttons, a window appears with a text box and the next button. Clicking on the next button will load another window using the fields, hiding the first one. The number of fields in the second form should be adjusted in accordance with the user input in the first window. I am trying to use a for loop for this. The code I use as follows:

var win1, win 2, j;

var win1items = new Ext.form.FormPanel({
    //snip
    items: [{
        xtype: 'fieldset',
        defaultType: 'textfield',
        items: [{
            fieldLabel: 'Number',
            allowBlank: false,
            name: 'Number',
            width: 110,
            cls:"txtfield"
        }]
    }],
    buttons: [{
        text: 'Next',
        handler: function(){
            if(!win2){
                winc2 = new Ext.Window({
                    //snip
                    items: [win2items]
                });
            }

            win2.show(this);
            win1.hide();
        }
    }]
});

j = Ext.getCmp('win1').getForm().findField("Number").getValue();
var fldComs = [];

for (i=0; i<=j; i++){
    fldComs[i] =  new  Ext.form.FieldSet({
        //snip
        items: [{
        //snip
        }]
    });
}

win2items = new Ext.form.FormPanel({
    //snip
    items: [fldComs]
});

Ext.onReady(function(){
    new Ext.Toolbar({
        renderTo: document.body,
        items: [{
            xtype: 'tbbutton',
            text: 'Start Here',
            cls: 'menu-icon',
            handler: function(){
                if(!win1){
                    win1 = new Ext.Window({
                        //snip
                        items: [win1items]
                    });
                }
                win1.show(this);
            }
        }]
    });
});

The error I get is

Uncaught TypeError: Unable to call getForm method from undefined.

However, if I use a fixed value in a for loop, say 5, I get the desired result. I am using Ext 3.2.1

+5
source share
2

, - , , , - , :

1) Ext.getCmp('win1') , "win1" - :

    var win1items = new Ext.form.FormPanel({
        id: 'win1'
        ...

2) , "win1" , , , , MMT, Ext.Window getForm() ( , , ).

3) , ID:

[{
    label: 'Number',
    xtype: 'textfield',
    id: 'MyNumberField'
}]
... 
var j = Ext.getCmp('MyNumberField').getValue();
+10

getCmp() id , . getCmp().

, , fat skat

0

All Articles