0
var confirmWindow = Ext.create('Ext.window.Window', {
     title: 'Selected Item List',
     autoHeight: true,
     width: 500,
     layout: 'fit',
     modal: true,
     items: [{
        xtype: 'panel',
        bodyPadding : 5,
        items: [{
           xtype: 'textfield',
           id : 'freightFee',
           fieldLabel: 'Freight Fee ',
           name : 'freight' // I need this value, when I click the button
        }]
     }],
     bbar: ['->', {
         xtype: 'buttongroup',
         items: [{
           text: "test",
           handler: function () {
              // I want to get the textfield value (freightFee)
              var freightFee = Ext.getCmp('freightFee').getValue(); // error :Ext.getCmp('freightFee') is undefined
                }
            }]
            }
        });

上記のようなウィンドウがあり、ボタンをクリックしたときにテキスト入力ボックスの値を取得したいと考えています。

私は試した、

var freightFee = Ext.getCmp('freightFee').getValue();

しかし、エラーメッセージは言う、

Ext.getCmp('freightFee') は定義されていません

誰もこれを知っていますか?

ありがとう!

4

1 に答える 1

-2

今まで使用しないでくださいgetCmp!それは非常に高価で不必要です。up/down要素の親/子を見つけるためのメソッドを確認してくださいhttp://docs.sencha.com/ext-js/4-0/#!/api/Ext.Element-method-down

あなたの場合、そのようなものが機能するはずです:

handler: function(button) {
   var tf = button.up('window').down('#freightFee');
}
于 2012-05-16T20:26:55.080 に答える