In case you have a db which does not support kep calendar fields, we can create/update data on fly for calendar fields like..id, cid, startDate, endDate etc
In the code below, we did not have calender id, event id, startDate, endDate, Title... using conver:function(), you can utilize available data coming from db to create necessary info for creating events and calendar..
- Code: Select all
Extensible.calendar.data.EventMappings = {
EventId: {
name: 'ID',
mapping: 'evt_id',
type: 'string',
convert: function(newValue, model) {
return Ext.Date.format(model.data.TransDate, 'Ymd').toString() + '-' + model.data.TimeFrom.toString() + '-' + model.data.TimeTo.toString();
}
},
CalendarId: {
name: 'CalID',
mapping: 'cal_id',
type: 'string',
convert: function(newValue, model) {
return '1';
}
},
Title: {
name: 'EvtTitle',
mapping: 'evt_title',
convert: function(newValue, model) {
return 'Normal Hours';
}
},
StartDate: {
name: 'StartDt',
mapping: 'start_dt',
type: 'date',
dateFormat: 'c',
convert: function(newValue, model) {
debugger;
var timeFrom = model.data.TimeFrom.toString();
var hours;
if (timeFrom.length == 3)
hours = timeFrom.substr(0, 1);
else
hours = timeFrom.substr(0, 2);
var mins = model.data.TimeFrom.toString().substr(2, 3);
var date = Ext.Date.clearTime(new Date());
return Ext.Date.add(date, Ext.Date.SECOND, parseInt(hours) * 3600 + parseInt(mins) * 60);
}
},
EndDate: {
name: 'EndDt',
mapping: 'end_dt',
type: 'date',
dateFormat: 'c',
convert: function(newValue, model) {
debugger;
var timeTo = model.data.TimeTo.toString();
var hours;
if (timeTo.length == 3)
hours = timeTo.substr(0, 1);
else
hours = timeTo.substr(0, 2);
var mins = timeTo.substr(2, 3);
var date = Ext.Date.clearTime(new Date());
return Ext.Date.add(date, Ext.Date.SECOND, parseInt(hours) * 3600 + parseInt(mins) * 60);
}
},
RRule: { name: 'RecurRule', mapping: 'recur_rule' },
Location: { name: 'Location', mapping: 'location' },
Notes: {
name: 'Desc',
mapping: 'full_desc',
convert: function(newValue, model) {
return 'Normal Hours';
}
},
Url: { name: 'LinkUrl', mapping: 'link_url' },
IsAllDay: { name: 'AllDay', mapping: 'all_day', type: 'boolean' },
Reminder: { name: 'Reminder', mapping: 'reminder' },
// We can also add some new fields that do not exist in the standard EventRecord:
CreatedBy: { name: 'CreatedBy', mapping: 'created_by' },
IsPrivate: { name: 'Private', mapping: 'private', type: 'boolean' },
Client: { name: 'Client', mapping: 'client', type: 'string' },
ResourceId: { name: 'ResourceId', mapping: 'resourceId', type: 'string' },
PostId: { name: 'PostId', mapping: 'postId', type: 'string' },
TransDate: { name: 'TransDate', mapping: 'transDate', type: 'date' },
TimeFrom: { name: 'TimeFrom', mapping: 'timeFrom', type: 'int' },
TimeTo: { name: 'TimeTo', mapping: 'timeTo', type: 'int' },
NormalHours: { name: 'NormalHours', mapping: 'normalHours', type: 'double' }
};
Extensible.calendar.data.EventModel.reconfigure();