2011-11-02 4 views
0

Sencha touch를 처음 사용하여 문제를 해결하기 위해 도움이 필요합니다. 다음 JSON 및 Sencha 터치 코드를 사용하여 어린이 텍스트 목록을 표시하려고합니다. 나는 API 철저한보고 및 아동의 데이터에 액세스 할 수 있다는 것을 발견,하지만 난Sencha touch - 중첩 된 JSON 데이터의 하위 요소 표시

  • 아이 (22)
  • 아이 (21) 목록을 표시 패널/스토어가 다시 보낼 수있는 방법을 잘 모르겠습니다

    { 
        "items":[ 
         { 
         "id":"1", 
         "text": "Parent 1", 
         "leaf": false, 
         "items": [ 
           { 
            "id":1, 
            "text": "child 1", 
            "leaf": true 
           }, 
           { 
            "id":2, 
            "text": "child 2", 
            "leaf": true 
           } 
         ] 
        }, 
        { 
         "id":"2", 
         "text": "Parent 2", 
         "leaf": false, 
         "items": [ 
          { 
           "id":3, 
           "text": "child 21", 
           "leaf": true 
          }, 
         { 
           "id":4, 
           "text": "Child 22", 
           "leaf": true 
          } 
         ] 
         } 
        ] 
        } 
    

    지금 내 엽차 터치 코드는 다음과 같다 :

    다음과 같이

나는 JSON 데이터를 중첩 한

Ext.ns('MyApp'); 
    MyApp.Child= Ext.regModel(Child, { 
    fields: ['id','text','day','date'], 
    belongsTo: 'Parent', 
    idProperty:'id', 
    proxy: { 
     type: 'rest', 
     url: 'test.json' 
    } 
    }); 
    MyApp.Parent = Ext.regModel('Parent', { 
    fields: [ 
     {name: 'id', type: 'int'}, 
     {name: 'text', type: 'string'} 
    ] , 
     associations: [ 
      { type: 'hasMany', model: 'Child', name: 'items'} 
     ], 
     proxy: { 
     type: 'ajax', 
     url: 'test.json' 
    } 

    }); 
    MyApp.parentStore = new Ext.data.Store({ 
    model : 'Parent', 
    proxy: { 
     type: 'rest', 
     url: 'test.json', 
     reader: { 
      type: 'json', 
      root : 'items' 
     } 
     }, 

     autoLoad:true 
    }); 

    MyApp.parentStore.filter('id','2'); 

// Do something here to get the list of child items. 

// MyApp.childStore = ? 

    MyApp.appList = new Ext.Panel ({ 
     fullscreen : true, 
     dockedItems : [ 
      { 
        xtype : 'toolbar', 
        title : 'Applications', 
        dock : 'top' 
      } 
     ], 
     items: [{ 
     xtype: 'list', 
     store: MyApp.childStore, // ?????? 
     itemTpl: '<div class="contact"><strong>{text}</strong></div>' 
    }]      

}); 

답변

관련 문제