ext-ui.com

Ext JS 3.3 日历组件


在Ext中设计一个标准的日历组件并不是一件简单的事情.既不能把它设计复杂到用起来比较困难,又不能设计得简单到只能拿来当例子,脱离了实际的用途.我们在这两者这间作了平衡,希望你们同意.

开始了解日历面板
主要组成部分:
*月视图这个视图渲染使用了MonthViewTemplate.它会自动适应屏幕尺寸,不会出现滚动条.它基于box布局.
*日视图这个视图使用了两个组件:DayHeaderView(由DayHeaderTemplate渲染)和DayBodyView(由DayBodyTemplate渲染)DayHeaderView里面是全日事件,而DayBodyView则是除了非全日活动外的所有活动.
*周视图这个视图仅仅是扩展了日视图,重复了7天.所以它并不需要一个单独的模板.

日历控件配置

1.monthViewCfg: {
2.    showHeader: true,
3.    showWeekLinks: true,
4.    showWeekNumbers: true
5.}

处理事件数据

1.Ext.calendar.EventMappings.Title.mapping = 'my-title'; // remap to a custom id
2.Ext.calendar.EventMappings.EndDate.name = 'END';       // remap the field name
3.Ext.calendar.EventRecord.reconfigure();

绑定所有

01.// Set up the data stores used by the calendar
02.this.calendarStore = new Ext.data.JsonStore({
03.    // config options
04.});
05.this.eventStore = new Ext.data.JsonStore({
06.    // config options
07.});
08.  
09.// Set up the UI
10.new Ext.Viewport({
11.    layout: 'border',
12.    items: [{
13.        id: 'app-header',
14.        region: 'north',
15.        // etc. -- static header area
16.    },{
17.        id: 'app-center',
18.        region: 'center',
19.        layout: 'border',
20.        items: [{
21.            id:'app-west',
22.            region: 'west',
23.            // etc. -- sidebar region configs
24.        },{
25.            // This is the start of the calendar
26.            xtype: 'calendarpanel',
27.            region: 'center',
28.  
29.            // Tie the data stores to the calendar
30.            eventStore: this.eventStore,
31.            calendarStore: this.calendarStore,
32.  
33.            // Configure views as needed
34.            monthViewCfg: {
35.                showWeekLinks: true
36.            },
37.  
38.            // CalendarPanel-specific configs as needed
39.            showTime: false
40.  
41.            // Set up event listeners -- see the sample app code for the full list
42.            listeners: {
43.                'eventclick': {
44.                    fn: function(vw, rec, el){
45.                        // etc.
46.                    },
47.                    scope: this
48.                },
49.                'eventadd': {
50.                    fn: function(cp, rec){
51.                        // etc.
52.                    },
53.                    scope: this
54.                },
55.                // etc. -- there are a lot of these
56.                // These handlers allow the app code to coordinate between
57.                // components and the overall UI so that the components
58.                // don't have to know about each other.
59.            }
60.        }]
61.    }]
62.});

但对于...
正如前面提到,真正的日历程序还需要完成很多额外的功能.举个例子,如定期提醒,邀请与会者功能等等.如果您需要一个完整的日历程序,可以留意我们的日历专业版.

英文原文:
http://www.sencha.com/blog/2010/09/08/ext-js-3-3-calendar-component/

作者:小强占卜师
出处:http://extjs.org.cn
本文版权归作者和ExtJs中文资讯站共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接。