2012-07-24 33 views
0

我有一個窗口。和一些字段(文本框和按鈕)。現在我想提交這些細節。從窗口獲取字段值

我得到這個錯誤:

TypeError: button.up("form").getValues is not a function 

按鍵功能

buClicked : function (button,record) { 
var val= button.up('form').getValues(); 
console.log(val.textfieldValue); 
} 

我的婚姻定義

Ext.define('MyApp.view.WindowForm', { 
    extend: 'Ext.window.Window', 
    alias: 'widget.winform', 
    id: 'winformid', 

回答

3
var val= button.up('form').getForm().getValues(); 
+0

謝謝。這工作'var val = button.up('window')。down('form')。getForm()。getValues();' – Illep 2012-07-24 23:41:38

0

你是在擴展Window's class這是好的,但也添加項目配置wh您將包括xtype:form,其配置有the textfield and the buttons config這樣的事情:

Ext.define('MyApp.view.WindowForm', 
     { 
      extend:'Ext.window.Window', 
      id:'myformvin', 
      items:[ 
       {xtype:'form',items:[{xtype:'textfield',fieldLabel:'My name',name:'myname'}], 
       buttons:[{xtype:'button',text:'save',handler:function(btn){ 
         var val = btn.up('form').getForm().getValues(); 
         console.log(val); //to confirm that you have the values 
        } 
       }] 
       } 
      ] 
     } 
);