2012-01-10 102 views
1
I am unable to load the below xml in to List using Sencha. 

<?xml version="1.0" encoding="UTF-8"?> 
<bdayevents> 
<bdayevent>Acceptance Letters</bdayevent> 
<bdayevent>Acceptance Letters</bdayevent> 
</bdayevents> 

This is the model which i am trying to use as there are no attributes to my XML. 

Ext.regModel('BEvent',{name:'bdayevent'}); 
var store = new Ext.data.Store({ model: 'BEvent', 
proxy: { 
type: 'ajax', 
url: 'http://localhost:8080/JSON/BirthdayInvitations.xml', 
reader: { 
type : 'xml', 
root : 'bdayevents', 
model : 'BEvent', 
record : 'bdayevent' 
} 
} 


}); 

這是我準備調用期間的列表。無法使用Sencha將數據從XML加載到列表中

var list = new Ext.List({ 
    fullscreen: true, 
    onItemDisclosure: { 
       scope: 'test', 
       //handler: makeJSONPRequest 


      }, 
    itemTpl : '{event}', 
    grouped : true, 
    indexBar: true, 
    store: store, 
    modal:true 
    }); 
list.show(); 

    } 


}); 

上述代碼片段的結果是索引顯示a到z的空白頁面。

請幫我解決這個問題。

感謝, 希亞姆

回答

0

試試這個

Ext.regModel('BEvent', { 
     fields: ['bdayevent'] 
    }); 
    var store = new Ext.data.Store({ 
     model: 'BEvent', 
     method:'get', 
     proxy: { 
      type: 'ajax', 
      url : 'BirthdayInvitations.xml', 
      //url: 'test1.xml', 
      reader: { 
       type : 'xml', 
       record: 'bdayevents' 
      } 
     }, 
     autoLoad: true 
    }); 
    var XMLTpl = new Ext.XTemplate(
     '<tpl for=".">', 
      '<div>{bdayevent}', 
     '</tpl>' 
    ); 
    var list = Ext.create('Ext.List', { 
     fullscreen: true, 
     store: store, 
     onItemDisclosure: {}, 
     itemTpl: XMLTpl 
    }); 
相關問題