2012-05-15 100 views
2

的元素我有一個字段:如何獲得一個字段

Ext.define('admin.view.BuzzEditForm', { 
    extend: 'Ext.form.Panel', 
    requires: ['Ext.form.FieldSet','Ext.Img'], 
    id: 'editorPanel', 
    xtype: 'buzzEditForm', 
    config: { 
     /* modal: true, 
     hideOnMaskTap: false, 
     centered: true, 
     width: 500, 
     scrollable: false,*/ 
     items: [{ 
      xtype: 'fieldset', 
      items: [ 
       { 
        xtype: 'textfield', 
        name: 'keyword', 
        label: 'Mots clés' 
       }, 
       { 
        xtype: 'textfield', 
        name: 'title', 
        label: 'Titre' 
       }, 
       { 
        id: 'editorPanelvisual', 
        xtype: 'field', 
        label: 'Visuel actuel', 
        component: 
        { 
         xtype: 'container', 
         layout: 'hbox', 
         items: [ 
          { 
           id: 'buzzImageField', 
           flex: 1, 
           xtype: 'image', 
           src: 'http://pierre.chachatelier.fr/programmation/images/mozodojo-original-image.jpg', 
           height: 200 
          }, 
          { 
           id: 'buzzChooseImageField', 
           xtype: 'button', 
           iconCls: 'arrow_right', 
           iconMask: true, 
           ui: 'action', 
           action: 'chooseBuzzImage' 
          } 

         ] 
        } 

       }, 
       { 
        xtype: 'textfield', 
        name: 'visual', 
        label: 'Visuel' 
       } 
      ] 
     }] 
    } 
}); 

我可以用Ext.getCmp讓我FormPanel中(「#editorPanel」),但我怎樣才能使用其名稱字段?

回答

3

只需使用Ext.ComponentQuery,例如:

Ext.ComponentQuery.query('textfield[name="keyword"]')

有關詳細信息,請參閱本:http://docs.sencha.com/touch/2-0/#!/api/Ext.ComponentQuery

+1

謝謝你,今天你幫了我很多:)我以sencha touch開始,所以我有很多問題。 – Sebastien

+0

你很受歡迎。我現在很忙,但希望能盡我所能幫助你們所有人。 :) –

+2

你犯了一個語法錯誤,它是:Ext.ComponentQuery.query('textfield [name =「keyword」]') – Sebastien

0

只是提一提,Ext.ComponentQuery.query('textfield[name="keyword"]')返回數組。因此,如果您只需要上述示例中的一個元素,則必須使用.pop()函數獲取最後一個元素,然後使用它進行操作。

相關問題