2013-07-18 92 views
1

請幫我解決這個問題..我花了太多的時間來整理出來.. 我有一個json文件我想要在dataview中顯示它..我可以顯示父值但不能讓孩子節點Sencha在Dataview中嵌套的json顯示

這是我的JSON格式

{ 
    "items": [ 
     { 
      "name": "Science Gallery", 

      "menu": [ 
       { 
        "commenttext": "SC Sandwich" 
       }, 
       { 
        "commenttext": "SC Toasted Sandwich" 
       }, 
       { 
        "commenttext": "SC Panini" 
       }, 
       { 
        "commenttext": "SC Ciabatta" 
       }, 
       { 
        "commenttext": "SC Burrito" 
       } 
      ] 
     } 

    ] 
} 

這是我的看法 /** * TouchCalendar.view.EventListPanel */

Ext.define('WinReo.view.PropertyDetailsView', { 
    extend: 'Ext.Panel', 

    requires: [ 
     'Ext.dataview.List', 
     'Ext.layout.Fit' 
    ], 

    alias: 'widget.propertydetailsview', 
    id:'propertydetailsview', 
    config: { 
     // title : 'Events List', 
     layout : 'fit', 
     store:'WinReo.store.PropertyDetails', 
     id:'propertydetailsview', 
     cls:'propertydetailscss', 


    }, 

    initialize: function(){ 


     var listadd = Ext.create('Ext.DataView', { 
      fullscreen: true, 
      id: 'ListePieces', 
      //itemTpl: listTemplate, 
      //data:[], 
      itemTpl: [ 
       '{name}', 
       '<div>', 
       '<h2><b>Menu</b></h2>', 
       '<tpl for="menu">', 
       '<div>{item}</div>', 
       '</tpl>', 
       '</div>' 
      ].join(''), 

      loadingText: 'Loading...', 
      store: storedetails 
      /*listeners:{ 
       itemtap: function(record, index){ 

       alert('hi'); 
       } 
      }*/ 

     }); 
     this.add(listadd); 


    } 

}); 

這裏是我的模型

Ext.define('WinReo.model.PropertyDetailsModel', { 
    extend: 'Ext.data.Model', 
    // requires: ['WinReo.model.PropertyDetailsModelComments'], 
    config: { 
     fields: [ 

      {name: 'name'}, 
      {name: 'commenttext'}, 
      {name: 'item'} 


     ] 
    } 


}); 

這裏是我的商店

Ext.define('WinReo.store.PropertyDetails', { 
    extend: 'Ext.data.Store', 
    requires: [ 
     'WinReo.model.PropertyDetailsModel', 

     'Ext.data.Store', 
     'Ext.dataview.DataView', 
     'Ext.data.NodeStore', 
     'Ext.data.TreeStore' 
    ], 

    config: { 
     storeId: 'propertydetails', 
     defaultRootProperty: 'items', 
     model: 'WinReo.model.PropertyDetailsModel', 
     autoLoad: true, 


     proxy: { 

      type: 'ajax', 
      method:'post', 
      url: 'resources/data/fullproperty.json', 
      //url: apiurl+'PropertyList.ashx?switch=GetPIP&reoid=', 

      reader: { 
       type: 'json', 
       rootProperty: 'items' 

      } 
     } 


    } 

}); 

我可以顯示與NORAM型號此嵌套的JSON,沒有任何模型關聯需要?

請幫助... UR幫助提前

+0

不要張貼問題,第二,如果你認爲你等着久的答案。更好的是編輯現有的得到(更好)的迴應 – sra

+1

對不起,我會刪除我以前的帖子..我太複雜了,我認爲.. – Dibish

回答

0
多appreciated..thanks

更改代理服務器設置在您的商店如下。我刪除「rootProperty」,添加「記錄」

proxy: { 
type: 'ajax', 
method:'post', 
url: 'resources/data/fullproperty.json', 
//url: apiurl+'PropertyList.ashx?switch=GetPIP&reoid=', 
reader: { 
    type: 'json', 
    record: 'items' 
} 

}

相關問題