2012-04-03 5 views
0

私はSencha Touch 2を使用しています。タイトルバーを作成して一連の画面に取り込む必要があります。 TitleBar要素はドロップダウンリストです。ドロップダウンリスト内のアイテムは動的でなければならず、データファイルからロードする必要があります。Sencha Touch 2 - 店舗を使用してタイトルバーに入れる

データを読み込むことができましたが、データをタイトルバーに戻すことはできません。言い換えれば、私は何とかタイトルバーへの参照を作成する必要があります。

コード:

Ext.define('CustomerToolbar', { 
extend: 'Ext.TitleBar', 


xtype: 'customer-toolbar', 


initialize: function() { 
    this.callParent(arguments); 

    this.loadItems(); 




    console.info("end of init");  
}, 


config: { 
    layout: 'hbox', 


    defaults: { 


    } 
}, 


loadItems: function (titleBar) { 
    var itemList = []; 
    var itemOptionList = []; 


    Ext.getStore('OrganizationStore').load(function(organizationList) { 


     console.info("getOptionList inside the store load function"); 


     Ext.each(organizationList, function(organization) { 


      console.info("organizations: " + organization.get("name") + "," + organization.get("id")); 
      itemOptionList.push({text: organization.get("name"), value: organization.get("id")}); 


     }); 


     console.info("itemList - about to populate"); 
     itemList.push(
      { 
       xtype: 'selectfield', 
       name: 'customerOptions', 
       id :'organizationId', 
       options: itemOptionList, 
       action :'selectOrganizationAction' 
      } 
     ); 
     console.info("itemList - populated"); 
     console.info("itemList within the store block: " + itemList); 


     console.info("this: " + this); 


     //THIS IS WHERE I AM HAVING THE PROBLEM. 
     //The variable this points to the store and not to the TitleBar 
     //this.setItems(itemList); 


    }); 


    console.info("itemList outside the store block: " + itemList); 
} 

})。

答えて

0

あなたのselectfieldにリスナーを追加し、

listeners:{ 
      change:function(){ 
       title = Ext.getCmp('organizationId').getValue(); 
       Ext.getCmp('TitlBarID').setTitle(title); 
      } 
     } 

を行うことができます私はExt.getCmpはファッショナブルではありません知っているが、それは、私は、コントローラにExt.getCmpを使用していますし、それが動作

+0

作品!どうもありがとう – alexgrimaldi

関連する問題