每当我点击spinnerfield, spinnerfield的值增加,我想动态地改变textfield的值

whenever i m click on spinnerfield the value increases of spinnerfield i want dynamically change the value of textfield value

本文关键字:spinnerfield 动态 改变 的值 textfield 增加      更新时间:2023-09-26

在这段代码中,我想每当点击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>',
           }
    ]
});
 }
});

您可以收听3个事件:'spin', 'spindown', 'spinup'。参考:http://docs.sencha.com/touch/1-1/# !/api/Ext.form.Spinner-event-spin

首先将"new Ext.Panel"更改为"var myppanel = new Ext.Panel",这样您就可以访问面板以获取文本字段并更改其内容。

然后为你的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");
        }
    }
},