我正在使用extjs bryntum calendar创建事件,并希望将它们保存为googleics文件,然后将事件再次加载到sch calendar中。
有谁能告诉我们如何从cal.model.event转换到ical events,反之亦然?数据来自api作为ical数据。
我的代码是:
资源存储:
Ext.define('my.store.CalendarResource', {
extend: 'Cal.data.ResourceStore',
storeId: 'resource',
// proxy: 'memory',
model:'my.model.CalendarResource',
proxy: {
type: 'rest',
url: 'api/calendars/scheduler'
},
});
资源模型:
Ext.define('my.model.CalendarResource', {
extend : 'Cal.model.Resource',
fields: [{
name: 'Id',
type:'string'
}, {
name: 'Name',
type: 'string'
}, {
name: 'Color',
type: 'string'
}, {
name: 'data'
}]
});
日历视图
Ext.define('my.view.RecurrenceCalendar', {
extend : 'Cal.panel.Calendar',
xtype : 'recurrencecalendar',
requires : [
'Sch.data.util.recurrence.Legend',
'my.store.CalendarEvent',
'my.store.CalendarResource'
],
date : new Date(),
eventStore : 'event',
resourceStore : 'resource',
// show the resource filter
resourceFilter : {
dock : 'right'
},
// Uncomment the below line to disable the recurring events feature
// recurringEvents : false,
initComponent : function () {
var me = this;
Ext.apply(me, {
eventRenderer : function (eventRecord, resourceRecord, tplData) {
var legend = '';
if (me.recurringEvents && eventRecord.getRecurrence()) {
legend = Sch.data.util.recurrence.Legend.getLegend(eventRecord.getRecurrence(), eventRecord.getStartDate());
}
return eventRecord.getName() + (legend ? ' | ' + legend : '');
},
beforeeventadd : function (me, eventRecord, resources, eOpts) {
var resourceStore = me.getResourceStore();
alert('aaaaaaa')
}
});
me.on('eventclick', function ( view, record, e ) {
var el = e.getTarget(me.getSchedulingView().eventSelector, 10, true);
me.editor.edit(record, el);
});
me.on('eventdbclick', function ( view, record, e ) {
var el = e.getTarget(me.getSchedulingView().eventSelector, 10, true);
me.editor.edit(record, el);
});
me.on('beforeeventadd',function(me, eventRecord, resources, eOpts){
alert('123')
});
Ext.getStore('resource').reload();
me.callParent(arguments);
},
onEventCreated : function (newEventRecord, resources) {
// Overridden to provide some default values
var resourceStore = this.getResourceStore();
if (!newEventRecord.getResourceId()) {
if (!Ext.isEmpty(resources)) {
newEventRecord.assign(resources);
} else if (resourceStore && resourceStore.getCount() > 0) {
newEventRecord.assign(resourceStore.first());
}
}
},
});
事件存储:
Ext.define('my.store.CalendarEvent', {
extend : 'Cal.data.EventStore',
storeId : 'event',
});
谢谢您。
1条答案
按热度按时间abithluo1#
你做了什么?
将记录另存为icalendar文件:
您可以从中序列化记录
store
格式化.ical
格式(https://www.ietf.org/rfc/rfc2445.txt).要将文件作为事件加载:
你可以听
change
在file
输入和解码.ical
设置模型参数的格式。您可以使用现有的开源库,如https://github.com/nwcell/ics.js