1

我对以下 javascript 有疑问:

var stereo_form =new Ext.form.FormPanel({
        id: "stereoInfo_panel",
        autoDestroy:true,
        frame: true,
        width: 410,
        items:[{
            xtype: 'textfield',
            fieldLabel: 'DEM Resolution',
            name: 'resolution',
            value: '0.005' //sets a default value

        },{
            xtype: 'textfield',
            fieldLabel: 'Pyramid Level',
            name: 'matching',
            value: '0' //sets a default value

        },{
            xtype: 'textfield',
            fieldLabel: 'Size of DEM',
            name: 'size',
            value: '50.00' //sets a default value

        }],
            buttons: [{
                text: 'Confirm',
                handler: function()
                        {
                               // user1 = value of resolution field
                                                // user2 = value of matching field
                                                // user3 = value of size field
                            w.close();
                        }

        }]
    }); 

    var w =new Ext.Window({
        id: "stereoInfo_win",
        title: "Stereo Reconstruction Parameters",
        layout: 'form',
        height: 152,
        width: 415,
        items: stereo_form

    });

因此,当按下“确认”按钮时,我需要为三个 user1、user2 和 user3 变量分配表单字段分辨率、匹配和大小的值,我该怎么做?

詹姆士

4

1 回答 1

1

试试这个:

var w = new Ext.Window({
        id: "stereoInfo_win",
        title: "Stereo Reconstruction Parameters",
        layout: 'form',
        height: 152,
        width: 415,
      items: {
        xtype: 'form',
        id: "stereoInfo_panel",
        frame: true,
        width: 410,
        items:[{
            xtype: 'textfield',
            fieldLabel: 'DEM Resolution',
            name: 'resolution',
            value: '0.005' //sets a default value

        },{
            xtype: 'textfield',
            fieldLabel: 'Pyramid Level',
            name: 'matching',
            value: '0' //sets a default value

        },{
            xtype: 'textfield',
            fieldLabel: 'Size of DEM',
            name: 'size',
            value: '50.00' //sets a default value

        }],
            buttons: [{
                text: 'Confirm',
                handler: function(btn)
                 {

                 // console.log(Ext.getVersion()); // uncomment to know your extjs version

                 // traverse to the form object, then get the fields values
                 var values = btn.findParentByType('form').getForm().getValues();

                  user1 = values['resolution'];
                 user2 = values['matching'];
                 user3 = values['size'];

                 // traverse up again to the window object
                 btn.findParentByType('window').close();
             }

        }]
    }

});
于 2012-08-28T08:38:13.510 回答