无法使用Sencha将数据从XML加载到列表

时间:2012-01-10 12:56:13

标签: sencha-touch

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'
}
}


});

这是我准备在调试期间调用的List。

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。

请帮我解决这个问题。

谢谢, 希亚姆

1 个答案:

答案 0 :(得分: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
    });