2012-12-12 9 views
0

스토어 오브젝트는 아약스 요청을 통해 동적으로로드됩니다. 콘솔에서 디버깅하는 동안 나는 저장소 개체가 레코드로 채워지지만 리스트는이 비어 있음을 볼 수 있습니다.Sencha Touch 2. 빈 목록

코드 :

뷰포트보기

Ext.define('sample.views.Viewport', { 
    extend: 'Ext.tab.Panel', 

    title: 'Hello world!', 

    xtype: 'viewport', 

    config: { 
     fullscreen: true, 

     tabBar: { 
      docked: 'bottom', 
     }, 

     items: [ 
      { xclass: 'sample.views.wares.lists.Popular' }, 
     ] 
    } 
}); 

NavigationView보기

Ext.define('sample.view.wares.lists.Popular', { 
    extend: 'Ext.NavigationView', 

    xtype: 'Popular', 

    config: {  
     iconCls: 'home', 
     title: 'Pop. prekės', 

     items: [ 
      { 
       xtype: 'wares',               
      } 
     ] 
    } 
}); 

목록보기

Ext.define('sample.views.wares.lists.List', { 
    extend: 'Ext.List', 

    xtype: 'wares', 

    config: { 
     store: 'Wares', 
     itemTpl: '{Name}' 
    }, 

    initialize: function() { 
     this.config.title = sample.app.title; 
    } 
});  

동적 아약스 재를 통해로드 된 기록의 저장소 개체 탐구.

Ext.define('sample.store.Wares', { 
    extend: 'Ext.data.Store', 

    config: { 
     model: "sample.models.WaresListItem" 
    } 
}); 

Result in Ripple emulator

답변

1
initialize: function() { 
    this.config.title = sample.app.title; 
    this.callParent(); 
} 

"this.callParent()"당신이 기능을 초기화하는 경우는 부모 (귀하의 경우 'Ext.dataview.List')를 호출 특정 기본 작업을 수행하는 데 요구하기 때문에 중요하다 목록을 구성해야합니다. 이것은 java의 constructor로부터 super를 호출하는 것과 유사합니다.

하면 여전히 블록을 모두

2

당신이 컨테이너의 레이아웃을 정의하지 않았기 때문에 그것의 내부 구성 요소가 표시되지 않는 대부분의 시간.

시도는 다음과 같이 당신의 탐색 뷰의 설정에 레이아웃을 추가 :

config: {  
    iconCls: 'home', 
    title: 'Pop. prekės', 
    layout: 'fit', 
    items: [ 
     { 
      xtype: 'wares',               
     } 
    ] 
} 

희망이 참조

을하는 데 도움이 : 여기 RDougan의 대답 : 공식에서 How do I make a dataview.list visible in Sencha Touch 2?

+0

같은 결과를 초기화 할 필요가 없을 것입니다 당신은 선언 블록

this.config.title = sample.app.title; 

이 이동할 수 있으며이

config: { store: 'Wares', itemTpl: '{Name}', title: sample.app.title }, 

같이 할 경우. 레이아웃 구성이 목록을 표시하는 데 영향을 미치지 않았습니다. –

0

몇 번 검토 샘플 응용 프로그램 문서 및 문제는 함수를 initialize 함수로 호출하여 해결되었습니다. 왜 아직 모릅니다.

initialize: function() { 
    this.config.title = sample.app.title; 
    this.callParent(); 
}