Upgrade to ExtJS 3.3.0 - Released 10/06/2010
[extjs.git] / examples / docs / source / EventRecord.html
1 <html>
2 <head>
3   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />    
4   <title>The source code</title>
5     <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
6     <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
7 </head>
8 <body  onload="prettyPrint();">
9     <pre class="prettyprint lang-js">/*!
10  * Ext JS Library 3.3.0
11  * Copyright(c) 2006-2010 Ext JS, Inc.
12  * licensing@extjs.com
13  * http://www.extjs.com/license
14  */
15 <div id="cls-Ext.calendar.EventMappings"></div>/**
16  * @class Ext.calendar.EventMappings
17  * @extends Object
18  * A simple object that provides the field definitions for EventRecords so that they can be easily overridden.
19  */
20 Ext.calendar.EventMappings = {
21     EventId: {
22         name: 'EventId',
23         mapping: 'id',
24         type: 'int'
25     },
26     CalendarId: {
27         name: 'CalendarId',
28         mapping: 'cid',
29         type: 'int'
30     },
31     Title: {
32         name: 'Title',
33         mapping: 'title',
34         type: 'string'
35     },
36     StartDate: {
37         name: 'StartDate',
38         mapping: 'start',
39         type: 'date',
40         dateFormat: 'c'
41     },
42     EndDate: {
43         name: 'EndDate',
44         mapping: 'end',
45         type: 'date',
46         dateFormat: 'c'
47     },
48     Location: {
49         name: 'Location',
50         mapping: 'loc',
51         type: 'string'
52     },
53     Notes: {
54         name: 'Notes',
55         mapping: 'notes',
56         type: 'string'
57     },
58     Url: {
59         name: 'Url',
60         mapping: 'url',
61         type: 'string'
62     },
63     IsAllDay: {
64         name: 'IsAllDay',
65         mapping: 'ad',
66         type: 'boolean'
67     },
68     Reminder: {
69         name: 'Reminder',
70         mapping: 'rem',
71         type: 'string'
72     },
73     IsNew: {
74         name: 'IsNew',
75         mapping: 'n',
76         type: 'boolean'
77     }
78 };
79
80 <div id="cls-Ext.calendar.EventRecord"></div>/**
81  * @class Ext.calendar.EventRecord
82  * @extends Ext.data.Record
83  * <p>This is the {@link Ext.data.Record Record} specification for calendar event data used by the
84  * {@link Ext.calendar.CalendarPanel CalendarPanel}'s underlying store. It can be overridden as 
85  * necessary to customize the fields supported by events, although the existing column names should
86  * not be altered. If your model fields are named differently you should update the <b>mapping</b>
87  * configs accordingly.</p>
88  * <p>The only required fields when creating a new event record instance are StartDate and
89  * EndDate.  All other fields are either optional are will be defaulted if blank.</p>
90  * <p>Here is a basic example for how to create a new record of this type:<pre><code>
91 rec = new Ext.calendar.EventRecord({
92     StartDate: '2101-01-12 12:00:00',
93     EndDate: '2101-01-12 13:30:00',
94     Title: 'My cool event',
95     Notes: 'Some notes'
96 });
97 </code></pre>
98  * If you have overridden any of the record's data mappings via the Ext.calendar.EventMappings object
99  * you may need to set the values using this alternate syntax to ensure that the fields match up correctly:<pre><code>
100 var M = Ext.calendar.EventMappings;
101
102 rec = new Ext.calendar.EventRecord();
103 rec.data[M.StartDate.name] = '2101-01-12 12:00:00';
104 rec.data[M.EndDate.name] = '2101-01-12 13:30:00';
105 rec.data[M.Title.name] = 'My cool event';
106 rec.data[M.Notes.name] = 'Some notes';
107 </code></pre>
108  * @constructor
109  * @param {Object} data (Optional) An object, the properties of which provide values for the new Record's
110  * fields. If not specified the {@link Ext.data.Field#defaultValue defaultValue}
111  * for each field will be assigned.
112  * @param {Object} id (Optional) The id of the Record. The id is used by the
113  * {@link Ext.data.Store} object which owns the Record to index its collection
114  * of Records (therefore this id should be unique within each store). If an
115  * id is not specified a {@link #phantom}
116  * Record will be created with an {@link #Record.id automatically generated id}.
117  */
118  (function() {
119     var M = Ext.calendar.EventMappings;
120
121     Ext.calendar.EventRecord = Ext.data.Record.create([
122     M.EventId,
123     M.CalendarId,
124     M.Title,
125     M.StartDate,
126     M.EndDate,
127     M.Location,
128     M.Notes,
129     M.Url,
130     M.IsAllDay,
131     M.Reminder,
132     M.IsNew
133     ]);
134
135     <div id="method-Ext.calendar.EventRecord-EventRecord.reconfigure"></div>/**
136      * Reconfigures the default record definition based on the current Ext.calendar.EventMappings object
137      */
138     Ext.calendar.EventRecord.reconfigure = function() {
139         Ext.calendar.EventRecord = Ext.data.Record.create([
140         M.EventId,
141         M.CalendarId,
142         M.Title,
143         M.StartDate,
144         M.EndDate,
145         M.Location,
146         M.Notes,
147         M.Url,
148         M.IsAllDay,
149         M.Reminder,
150         M.IsNew
151         ]);
152     };
153 })();
154 </pre>    
155 </body>
156 </html>