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 の 3 つの変数が必要ですが、どうすればよいですか?

ジェームズ

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 に答える