2011-11-12 19 views
0

在那段代碼中,我想每當點擊spinnerfield時,spinnerfield的值就會增加,這個時候動態地改變textfield值的值。無論何時我點擊spinnerfield我想要spinnerfield的值增加動態地改變文本域的值

Ext.setup 
({ 
    icon: 'icon.png', 
    tabletStartupScreen: 'tablet_startup.png', 
    phoneStartupScreen: 'phone_startup.png', 
    glossOnIcon: false, 
    onReady: function() 
    { 

new Ext.Panel 
({ 

    fullscreen:'true', 

     items:[ 
       { 
       xtype : 'spinnerfield', 
       name:'sp', 
       width:'20%', 
        height:'13%', 
       minValue: 0, 
       }, 
      { 
       xtype:'textfield', 
        name:'price', 
       height:'13%', 
        width:'8%', 
        html:'<b>350</b>', 
      } 

    ] 

}); 

} 

}); 

回答

0

您可以聽3個事件:'旋轉','旋轉','旋轉'。 參考:http://docs.sencha.com/touch/1-1/#!/api/Ext.form.Spinner-event-spin

首先將「new Ext.Panel」更改爲「var myPanel = new Ext.Panel」,以便您可以訪問面板以獲取文本字段並更改其內容。

然後實現EventListener的爲您spinnerfield:

{ 
    xtype : 'spinnerfield', 
    name:'sp', 
    width:'20%', 
    height:'13%', 
    minValue: 0, 
    listeners: { 
     spin: function(thisSpinner, numberValue, directionString) { 
      // Get the text field: 
      var textField = yourPanel.items.get(1); 
      // Update the text field: 
      textField.setValue("your new value"); 
     } 
    } 
}, 
相關問題