ExtJs日历EventStore有帮助吗?

时间:2011-02-17 11:25:37

标签: extjs calendar store

我一直在努力设置一个使用ExtJs日历的baisc日历示例 我查看过示例和文档 Ext Calendar Pro
我很难让基本的日历示例起作用 我认为我的问题是我没有正确定义商店,我知道商店应该包含'Ext.calendar.EventRecord'类型的记录。
我应该用什么类型的商店/读者来阅读记录? 这是我的代码:

var recs = [];
rec = new Ext.calendar.EventRecord({
    StartDate: '2101-01-12 12:00:00',
    EndDate: '2101-01-12 13:30:00',
    Title: 'My cool event',
    Notes: 'Some notes'
});
recs[0] = rec;

store = new Ext.data.Store({
     data: recs,
     reader: new Ext.data.ArrayReader({
                fields: ['StartDate', 'EndDate', 'Title', 'Notes']
    })
});

Ext.apply(this, config, {
    title: 'calendar',
    layout: 'fit',
    activeItem: 1,
    eventStore: store
});//Ext.apply           

1 个答案:

答案 0 :(得分:2)

查看this示例,看起来您需要使用JsonStore(它有一个JsonReader):

    new Ext.data.JsonStore({
       id: 'eventStore',
       root: 'evts',
       data: eventList, // defined in event-list.js
       proxy: new Ext.data.MemoryProxy(),
       fields: Ext.calendar.EventRecord.prototype.fields.getRange(),
       sortInfo: {
          field: 'StartDate',
          direction: 'ASC'
       }   
    });

使用eventList定义如下:

var eventList = {
    "evts": [{
        "id": 1001,
        "cid": 1,
        "title": "Vacation",
        "start": today.add(Date.DAY, -20).add(Date.HOUR, 10),
        "end": today.add(Date.DAY, -10).add(Date.HOUR, 15),
        "ad": false,
        "notes": "Have fun"
    }]
}

如果您正在使用远程提供程序,只需更改EventStore中的data属性即可从网址加载。您的JSON响应应该在eventList定义的结构中。

希望有所帮助。