2013-05-12 66 views
0

我是sencha touch的新手。請參閱代碼在view.jsfieldset動態設置值sencha touch 2.2

 Ext.define("blackbutton.view.Setup.UserProfile", { 
     requires: [ 
      'Ext.form.*', 
      'Ext.form.Panel', 
      'Ext.form.FieldSet', 
      'Ext.field.Number', 
      'Ext.field.Spinner', 
      'Ext.field.Password', 
      'Ext.field.Email', 
      'Ext.field.Url', 
      'Ext.field.DatePicker', 
      'Ext.field.Select', 
      'Ext.field.Hidden', 
      'Ext.field.Radio', 
      'Ext.field.Slider', 
      'Ext.field.Toggle' 
     ], 

     extend: 'Ext.form.Panel', 
     xtype: 'SetupUserProfile', 
     id: 'SetupUserProfile', 
     config: { 
      //floating: true, 
      //centered: true, 
      cls: 'bb-popupForm', 
      modal: true, 
      width: "100%", 
      layout: 'fit', 
      height: "100%", 
      styleHtmlContent: true, 
      //title: 'Black Button', 
      //iconCls: 'black', 

      scrollable: true, 

      items: [{ 
       docked: 'top', 
       xtype: 'titlebar', 
       title: 'Profile', 

       items: [{ 
        xtype: 'button', 
        iconMask: true, 
        iconCls: 'reply', 
        //text: 'Back', 
        handler: function() { 

         //Code here?? 



        } 
       }] 
      }, 
      { 
       xtype: 'panel', 
       layout: 'vbox', 
       scrollable: true, 
       items: [{ 
        xtype: 'fieldset', 
        id:'SetupUserProfileFS', 
        title: 'Personal Info', 
        instructions: 'Please enter the information above', 
        defaults: { 
         labelWidth: '35%', 
         required: true 
        }, 
        items: [ 
        { 
         xtype: 'textfield', 
         id: 'BB_ID', 
         name: 'BB_ID', 
         label: 'BB ID', 


        }, 
        { 
         xtype: 'emailfield', 
         id: 'email', 
         name: 'email', 
         label: 'Email', 
         placeHolder: '[email protected]', 

        }, { 
         xtype: 'textfield', 
         id: 'fullName', 
         name: 'fullName', 
         label: 'Full Name', 
         placeHolder: 'John', 

        }, { 
         xtype: 'numberfield', 
         id: 'mobilePhone', 
         name: 'mobilePhone', 
         label: 'Mobile Phone', 
         placeHolder: '012567890', 

        }, 
        { 
         xtype: 'textfield', 
         id: 'DOB', 
         name: 'DOB', 
         label: 'Date of birth', 
         placeHolder: '30/03/1988', 

        }, 

        { 
         xtype: 'textfield', 
         id: 'mailingAddress', 
         name: 'mailingAddress', 
         label: 'Mailing Address', 
         placeHolder: 'No 11, Jalan taman desa, 54100 KL', 

        } 


        ] 
       }, 
        }] 
       }] 
      }] 
     } 
    }); 

我需要改變字段集值當我按下回覆按鈕下方

。任何示例?請給我解決方案。謝謝

回答

1

在您的處理程序中,您希望動態設置fieldset的值。所以你的按鈕的處理程序看起來像這樣:

... 
items: [ 
    { 
     xtype: 'button', 
     iconMask: true, 
     iconCls: 'reply', 
     handler: function() { 
      Ext.getCmp('BB_ID').setValue('New value for BB_ID field'); 
      Ext.getCmp('email').setValue('New value for email field'); 
      Ext.getCmp('fullName').setValue('New value for fullName field'); 
      Ext.getCmp('mobilePhone').setValue('New value for mobilePhone field'); 
      Ext.getCmp('DOB').setValue('New value for DOB field'); 
      Ext.getCmp('mailingAddress').setValue('New value for mailingAddress field'); 
     } 
    } 
] 
... 
+0

感謝兄弟。幫助我很多 – user998405 2013-05-13 04:27:05