2011-07-17 90 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。