2011-07-17 89 views
0

我正在將應用程序放在一起,並嘗試獲取詳細信息面板工作列表。我將它建立在Sencha列表視頻上,但不斷收到錯誤「TypeError:表達式結果'abc.artistList.setActiveItem'[undefined]不是函數。」當我嘗試點擊某個項目並顯示詳細信息面板時。完整的代碼如下:Sencha Touch:列表詳細信息.setActiveItem undefined

Ext.ns('abc', 'abc.panel', 'abc.store'); 

// Models _____________________________________________________________________ 
Ext.regModel('Artists', { 
    fields: ['firstName', 'lastName'] 
}); 


// Stores _____________________________________________________________________ 
abc.store.Artists = new Ext.data.Store({ 
    model: 'Artists', 
    proxy: { 
     type: 'ajax', 
     url: 'http://localhost:8888/abc/stores/artists.json', 
     reader: { 
      type: 'json', 
      root: 'artists' 
     } 
    }, 
    sorters: 'lastName', 
    getGroupString : function(record) { 
     return record.get('lastName')[0]; 
    }, 
    autoLoad: true 
}); 

abc.artistDetail = new Ext.Panel({ 
      id: 'detailpanel', 
      tpl: 'Hello, {firstName}!', 
      dockedItems: [ 
       { 
        xtype: 'toolbar', 
        items: [{ 
         text: 'back', 
         ui: 'back', 
         handler: function() { 
          abc.panel.Artists.setActiveItem('artistList', {type:'slide', direction:'right'}); 
         } 
        }] 
       } 
      ] 
     }); 

abc.artistList = new Ext.List({ 
    title: 'Artists', 
    store: abc.store.Artists, 
    fullscreen: true, 
    id: 'artistList', 
    itemTpl: '<div class="contact">{firstName} {lastName}</div>', 
    grouped: true, 
    onItemDisclosure: function(record, btn, index) { 
     abc.artistDetail.update(record.data); 
     abc.panel.Artists.setActiveItem('detailpanel'); 
    } 
}); 

abc.panel.Artists = Ext.extend(Ext.Panel, { 
    id: 'artists', 
    title: 'Artists', 
    layout: 'card', 
    fullscreen: true, 
    cardSwitchAnimation: 'slide', 
    iconCls: 'artists', 
    items: [abc.artistList, abc.artistDetail], 
}); 

abcPrimavera = new Ext.Application({ 
    name: "abcApp", 

    onReady: function() { 
     var app = new Ext.TabPanel({ 
      fullscreen: true, 
      animation: false, 
      tabBar: { 
       dock: 'bottom', 
       layout: { 
        pack: 'center' 
       } 
      }, 
      items: [ 
      new abc.panel.Artists()] 
     }); 
     } 
}); 

任何幫助將是輝煌的。

感謝

+0

在另一個論壇上回答的問題 - 我對上面的代碼進行了更正,因此它應該可以工作。 – Mike

+0

它是一個命名空間問題?您可能希望將解決方案作爲針對您自己的問題的答案發布,以實現SO社區的利益。 ;) –

回答

0
Ext.ns('abc', 'abc.panel', 'abc.store'); 

// Models _____________________________________________________________________ 
Ext.regModel('Artists', { 
    fields: ['firstName', 'lastName'] 
}); 


// Stores _____________________________________________________________________ 
abc.store.Artists = new Ext.data.Store({ 
    model: 'Artists', 
    proxy: { 
     type: 'ajax', 
     url: 'http://localhost:8888/abc/stores/artists.json', 
     reader: { 
      type: 'json', 
      root: 'artists' 
     } 
    }, 
    sorters: 'lastName', 
    getGroupString : function(record) { 
     return record.get('lastName')[0]; 
    }, 
    autoLoad: true 
}); 

abc.artistDetail = new Ext.Panel({ 
      id: 'detailpanel', 
      tpl: 'Hello, {firstName}!', 
      dockedItems: [ 
       { 
        xtype: 'toolbar', 
        items: [{ 
         text: 'back', 
         ui: 'back', 
         handler: function() { 
          Ext.getCmp('artists').setActiveItem('artistList', {type:'slide', direction:'right'}); //updated code 
         } 
        }] 
       } 
      ] 
     }); 

abc.artistList = new Ext.List({ 
    title: 'Artists', 
    store: abc.store.Artists, 
    fullscreen: true, 
    id: 'artistList', 
    itemTpl: '<div class="contact">{firstName} {lastName}</div>', 
    grouped: true, 
    onItemDisclosure: function(record, btn, index) { 
     abc.artistDetail.update(record.data); 
     Ext.getCmp('artists').setActiveItem('detailpanel'); //updated code 
    } 
}); 

abc.panel.Artists = Ext.extend(Ext.Panel, { 
    id: 'artists', 
    title: 'Artists', 
    layout: 'card', 
    fullscreen: true, 
    cardSwitchAnimation: 'slide', 
    iconCls: 'artists', 
    items: [abc.artistList, abc.artistDetail], 
}); 

abcPrimavera = new Ext.Application({ 
    name: "abcApp", 

    onReady: function() { 
     var app = new Ext.TabPanel({ 
      fullscreen: true, 
      animation: false, 
      tabBar: { 
       dock: 'bottom', 
       layout: { 
        pack: 'center' 
       } 
      }, 
      items: [ 
      new abc.panel.Artists()] 
     }); 
     } 
}); 

兩個部分上面更新代碼 - 用錯的語法定義itemDisclosure。