Sencha Touch XML 列表
您好,我有一个关于 Sencha Touch 的 XML 列表的问题。
我在 Sencha Touch 中加载一些 XML,我想将它们显示为列表:
这是我的代码: Sencha:
Ext.setup({
onReady: function() {
Ext.regModel('navModel', {
fields: [
{name:'id'},
{name:'title'}
]
});
var navi = new Ext.data.Store({
autoLoad:true,
model: 'navModel',
method: 'POST',
proxy: {
type: 'ajax',
url : 'navi.xml',
reader: {
type : 'xml',
root: 'menu',
record:'navigation'
}
}
});
var something = new Ext.List({
store: 'navi',
title: 'asdfasdf',
emptyText: 'No data',
fulscreen: true,
itemTpl: '{id} - {title}'
});
var rootPanel = new Ext.TabPanel({
fullscreen:true,
items:[something]
});
}
});
XML:
<?xml version="1.0" encoding="UTF-8"?>
<menu>
<navigation>
<id>1</id>
<title>Hello</title>
</navigation>
<navigation>
<id>2</id>
<title>Test</title>
</navigation>
</menu>
我可以读取 XML,但它没有在列表中显示它..出了什么问题?
感谢您的回答
Hei i have a Question about XML Lists with Sencha Touch.
I load some XML in Sencha Touch and i would like to display them as a List:
Here's my Code:
Sencha:
Ext.setup({
onReady: function() {
Ext.regModel('navModel', {
fields: [
{name:'id'},
{name:'title'}
]
});
var navi = new Ext.data.Store({
autoLoad:true,
model: 'navModel',
method: 'POST',
proxy: {
type: 'ajax',
url : 'navi.xml',
reader: {
type : 'xml',
root: 'menu',
record:'navigation'
}
}
});
var something = new Ext.List({
store: 'navi',
title: 'asdfasdf',
emptyText: 'No data',
fulscreen: true,
itemTpl: '{id} - {title}'
});
var rootPanel = new Ext.TabPanel({
fullscreen:true,
items:[something]
});
}
});
XML:
<?xml version="1.0" encoding="UTF-8"?>
<menu>
<navigation>
<id>1</id>
<title>Hello</title>
</navigation>
<navigation>
<id>2</id>
<title>Test</title>
</navigation>
</menu>
I can read the XML but it doesn't display it in the List.. what's wrong??
Thx for Answers
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试将 TabPanel 更改为 Container,也许对您有帮助!
Try to change the TabPanel to Container, that maybe help you!
您必须写出商店名称,不带引号。
对于所有遇到映射问题的人...
您必须在 sencha-touch.js 的末尾添加此解决方法:
这样您就可以使用“@attributename”访问 xml 的属性
,并且如果您想访问你写的子属性“childname@attributename”
我希望我能帮助你..为此搜索了几个小时..;)
You have to write the name of the store without the quote sign.
And for all who got problems with mapping...
you have to add this workaround on the end of sencha-touch.js:
so you can access the attribute of your xml with '@attributename'
and if you want to have access to the child attributes you write 'childname@attributename'
I hope i helped you.. searched some hours for this.. ;)