2013-02-15 2 views
3

NestedList에 JSON 데이터를로드하려고합니다. 나는 다음과 같은Sencha Touch 2 : '지정한 상점을 찾을 수 없습니다.'

Ext.define('VisitTCMIndy.view.Explore', { 
extend: 'Ext.Container', 
requires: [ 
    'Ext.data.TreeStore', 
    'Ext.dataview.NestedList', 
    'VisitTCMIndy.store.Exhibits', 
], 
xtype: 'explorecard', 
config: { 
    iconCls: 'compass1', 
    title: 'Explore', 
    layout: 'fit', 
    items: [ 
     { 
      xtype: 'titlebar', 
      docked: 'top', 
      title: 'Explore' 
     }, 
     { 
      xtype: 'nestedlist', 
      fullscreen: true, 
      store: 'VisitTCMIndy.store.Exhibits', 
      detailCard: { 
       html: 'Explore Details' 
      }, 
      listeners: { 
       leafitemtap: function(nestedList, list, index, target, record){ 
        var detailCard = nestedList.getDetailCard(); 
        detailCard.setHtml('Exhibit Title: '+ record.get('title')); 
       } 
      } 
     } 

    ] 
} 
}); 

내가 얻을 다음

Ext.define('VisitTCMIndy.store.Exhibits',{ 
requires: ['VisitTCMIndy.model.Exhibit', 'Ext.data.proxy.JsonP'], 
extend: 'Ext.data.TreeStore', 
config: { 
    model: 'VisitTCMIndy.model.Exhibit', 
    proxy: { 
     type: 'jsonp', 
     url: 'http://www.example.com/explore.php', 
     reader: { 
      type: 'json', 
      rootPropery: 'children' 
     } 
    } 
} 
}); 

내가 /app/view/Explore.js에서 다음보기에서 참조 /app/store/Exhibits.js

에서 다음 저장소에 저장 파일이 경고 및 나는 페이지로 이동 빈리스트 :

[Ext.dataview.NestedList #이 applyStore] 지정된 스토어를 찾을 수 없습니다 [WARN]

,

나는 인생을 앞두고 내가 뭘 잘못하고 있는지 알 수 없다.

답변

5

확인. 내 app.js 파일에 내 저장소와 모델을 선언해야했습니다. 그런 다음 클래스 정의의 나머지 부분없이 이름만으로 내 저장소를 참조하십시오. 그래서 app.js 파일에 다음을 추가했습니다.

models: ['Exhibit'], 
stores: ['Exhibits'], 

다음은 업데이트 된 Explore.js보기 파일입니다.

Ext.define('VisitTCMIndy.view.Explore', { 
extend: 'Ext.Container', 
requires: [ 
    'Ext.data.TreeStore', 
    'Ext.dataview.NestedList', 
    'VisitTCMIndy.store.Exhibits', 
], 
xtype: 'explorecard', 
config: { 
    iconCls: 'compass1', 
    title: 'Explore', 
    layout: 'vbox', 
    items: [ 
     { 
      xtype: 'titlebar', 
      docked: 'top', 
      title: 'Explore' 
     }, 
     { 
      xtype: 'nestedlist', 
      store: 'Exhibits', 
      title: 'Museum Levels', 
      displayField: 'title', 
      detailCard: { 
       html: 'Explore Details' 
      }, 
      listeners: { 
       leafitemtap: function(nestedList, list, index, target, record){ 
        var detailCard = nestedList.getDetailCard(); 
        detailCard.setHtml('<div style="text-align:center;margin:.5em;"><img src="'+record.get('image')+'" alt="'+record.get('title')+'" />'+ 
         '<p style="text-align:left;">'+record.get('text')+'</p></div>' 
        ); 
       } 
      }, 
      flex: 1 
     } 

    ] 
} 
}); 

또한 레이아웃을 맞춤에서 vbox로 변경했습니다. 필자는이 작업을 수행하고 목록에 실제로 데이터를로드하고 있음을 보여주기 위해 목록에 1의 flex를 지정해야했습니다.