2012-02-06 11 views
2

私は、jsonファイルからツリーをロードすると、ループに入り、次のように(連続ループで)ツリーを表示します。extjs MVCを使用してjsonファイルから木をロードする

-A 
    -A 
    -A 
     -A 

マイJSON

{ 
    "success": true, 
    "results": [ 
     { "text": "number 1", "leaf": true }, 
     { "text": "number 2", "leaf": true }, 
     { "text": "number 3", "leaf": true }, 
     { "text": "number 4", "expanded": true, "children":[ 
      { "text": "number 4.1", "leaf": true }, 
      { "text": "number 4.2", "leaf": true }, 
      { "text": "number 4.3", "leaf": true } 
     ]}, 
     { "text": "number 5", "leaf": true } 
    ] 
} 

マイモデル

Ext.define('App.model.TreeModel', { 
    extend:'Ext.data.Model', 
    fields: [ 
      { name: 'text', type: 'string'} 
     ], 

     proxy:{ 
      type:'ajax', 
      url: 'data/tree.json', 
      reader:{ 
       type:'json', 
       root:'results' 
      } 
     } 
    }); 

ストア

Ext.define('App.store.MyTreeStore', { 
    extend: 'Ext.data.TreeStore', 
    requires: 'App.model.TreeModel', 
    model:'App.model.TreeModel', 
}); 

ビュー

Ext.define('App.view.MeetingTree', { 
    extend:'Ext.tree.Panel', 
    title:'Simple Tree', 
    store:'MyTreeStore', 
    alias:'widget.meetingtree', 
    rootVisible:false, 
    height:200 
}); 

私のinitファイル

Ext.application({ 
    name: 'App', 
    autoCreateViewport: true, 

    models: ['TreeModel'],  
    stores: ['MyTreeStore'], 

    launch: function() { 

    } 
}); 

いけないそのループ...誰もがアイデアを得た理由の手掛かりを持っていますか?事前に

おかげで

答えて

7

は最終的に解決

モデル

からライン

root:'results' 

を削除し、でJSONを星を見つけ

{ 
text: '.', 
children: [{ 

フルjson

{ 
text: '.', 
children: [{ 
    text:'Basic Ext Layouts', 
    expanded: true, 
    children:[{ 
     text:'Absolute', 
     id:'absolute', 
     leaf:true 
    },{ 
     text:'Accordion', 
     id:'accordion', 
     leaf:true 
    },{ 
     text:'Anchor', 
     id:'anchor', 
     leaf:true 
    },{ 
     text:'Border', 
     id:'border', 
     leaf:true 
    },{ 
     text:'Card (TabPanel)', 
     id:'card-tabs', 
     leaf:true 
    },{ 
     text:'Card (Wizard)', 
     id:'card-wizard', 
     leaf:true 
    },{ 
     text:'Column', 
     id:'column', 
     leaf:true 
    },{ 
     text:'Fit', 
     id:'fit', 
     leaf:true 
    },{ 
     text:'Table', 
     id:'table', 
     leaf:true 
    },{ 
     text:'vBox', 
     id:'vbox', 
     leaf:true 
    },{ 
     text:'hBox', 
     id:'hbox', 
     leaf:true 
    }] 
},{ 
    text:'Custom Layouts', 
    children:[{ 
     text:'Center', 
     id:'center', 
     leaf:true 
    }] 
},{ 
    text:'Combination Examples', 
    children:[{ 
     text:'Absolute Layout Form', 
     id:'abs-form', 
     leaf:true 
    },{ 
     text:'Tabs with Nested Layouts', 
     id:'tabs-nested-layouts', 
     leaf:true 
    }] 
}] 
} 
関連する問題