2012-04-26 4 views
0

내 Sencha 앱에 중첩 목록을로드하려고합니다. 문제는 내가 그것에 익숙하지 않은 및 json 파일을 내가 사용하고 있는지 확실하지 않은 경우입니다.중첩 목록이 sencha에로드되지 않습니다.

[ 
    { 
     "text":[ 


      { 
       "text":"1.1.1", 
       "leaf":true 

      }], 
     "text":[ 

      { 
       "text":"1.1.1", 
       "leaf":true 

      } 
     ] 


    } 
] 

이것은 내 점포 코드

//Defining the store for the Nested List 
Ext.define('InfoImage.store.nestedListStore', { 
    extend: 'Ext.data.TreeStore', 
    requires: 'InfoImage.model.nestedListModel', 
    id:'nestedListStore', 
    config:{ 

     //Calling the required model for the Work Item List 
     model : 'InfoImage.model.nestedListModel', 
     //Defining the proxy for the Work Item List to pull the data for the List 
     proxy : { 
      type : 'ajax', 
      url : 'app/model/data/list.json', 
      reader: { 
       type: 'json', 
       root: 'items' 

      } 
     }, 
     autoLoad: true 


    } 
}); 

이고 내 주 코드 표시

Ext.define("InfoImage.view.nestedList", { 
    extend:'Ext.NestedList', 
    xtype:'nestedList', 
    id:'nestedList', 

    config:{ 
     fullscreen:'true', 
     title:'Nested List', 
     xtype:'nestedList', 
     //displayField : 'text', 
     html:'Nested List on its way!!!', 
     store:'nestedListStore' 
     //itemTpl:'{text}' 
    } 
}); 

출력 이잖아 [개체 개체]이다. 나는 실종 된 것을 모른다. 어떤 도움을 주셔서 감사합니다.

답변

0

text은 모델 필드이기 때문에 JSON은 Ext.NestedList과 작동하지 않을 수 있으며 JSON 파일에서 rootProperty로 선언하면 안됩니다.

첫째,이 모델 정의가 있다고 가정 : 데이터에 따르면

Ext.define('ListItem', { 
    extend: 'Ext.data.Model', 
    config: { 
     fields: ['text'] 
    } 
}); 

를, 당신의 JSON 파일은 다음과 같아야합니다

items: [ 
{ 
    text: '1.1', 
    items: [ 
    { text: '1.1.1', leaf: true }, 
    { text: '1.1.2', leaf: true } 
    ] 
    } 
] 

을 당신은 당신의 상점이 설정을 추가해야 뿐만 아니라 defaultRootProperty: 'items'

1

먼저 Json은 VALID json입니다. 항상 두 번째 jsonlint.com

에 JSON을 붙여 유효한 JSON을 확인, 난 당신이

displayField:'text' 

속성을 주석 한 것을 알 수있다. displayFieldnestedlist에 제공하지 않으면 데이터 저장소의 어떤 항목이 목록에 표시되는지 알 수 없습니다.

아마, 당신이 [object Object]을 귀하의 o/p 목록에 포함시키는 이유입니다.

위 줄의 주석을 제거하고 확인하십시오.

+0

나는 그것을 사용해 보았지만 그 것이었다. 그래서 나는 그것이 올바른 코드인지 확인하기 위해 주석을 달았습니다. 나는 그것을 언 Commneted하고 다시 시도했다. 아직도 작동하지 않습니다. – Khush

+0

동일한 오류가 발생합니까? 모델 코드도 게시 할 수 있습니까? –

관련 문제