我正在嘗試使用sencha觸摸和手機來設置原生樣式的應用程序。我試圖將外部XML饋送中的數據引入模型中。如何使用Sencha/Phonegap將XML加載到列表中?
在我模型(Event.js)我有這樣的:
Ext.regModel('Event', {
fields: [
{name: 'title', type: 'string'}
]
});
在我店(eventsstore.js):
ToolbarDemo.eventstore = new Ext.data.Store({
model: 'Event',
sorters: 'title',
getGroupString : function(record) {
return record.get('title')[0];
},
proxy: {
type: 'ajax',
url: 'http://the-url-to-the-file.xml',
reader: {
type: 'xml',
root: 'events',
record: 'event'
}
},
autoLoad: true
});
並在視圖(試作爲列表):
ToolbarDemo.views.Eventscard = Ext.extend(Ext.List, {
title: "Events",
iconCls: "search",
store: ToolbarDemo.eventstore,
itemTpl: '{title}',
grouped: true,
indexBar: true,
cardSwitchAnimation: 'slide'
});
Ext.reg('eventscard', ToolbarDemo.views.Eventscard);
並試圖爲面板:
ToolbarDemo.views.Eventscard = Ext.extend(Ext.Panel, {
title: "Events",
iconCls: "search",
dockedItems: [{
xtype: 'toolbar',
title: 'Events'
}],
layout: 'fit',
items: [{
xtype: 'list',
store: ToolbarDemo.eventstore,
itemTpl: '{title}',
grouped: true
}],
//This was an experiment, safe to leave out?
initComponent: function() {
//ToolbarDemo.eventstore.load();
ToolbarDemo.views.Eventscard.superclass.initComponent.apply(this, arguments);
}
});
Ext.reg('eventscard', ToolbarDemo.views.Eventscard);
現在,當我瀏覽到該卡視圖,顯示加載覆蓋/微調但這是儘可能去,項的列表不出現。我做錯了什麼想法?
請參閱http://stackoverflow.com/questions/7676959/sencha-touch-xml-parsing -issue/7677538#7677538我給出了一些建議,幫助解決這類問題。你需要與你的Javascript調試器友好。 :-) – mmigdol
我看到了,但我似乎無法得到任何與它:(我真的不明白我應該怎麼做 –