Welcome › Forums › Customer Support › Events Calendar MySQL Data Store
Welcome › Forums › Customer Support › Events Calendar MySQL Data Store
| Wijmo Team Member | orchid1 posted on April 29, 2012 at 1:32 am Hey guys need some help understanding how to implement a custom data store for the events calendar using the “dataStorage” object that is passed the events calendar constructor. I originally asked the question in the community area but got no response so I went ahead and bought the support. I really hope you guys can help me here cuz I really need to get this thing working.
$(“#eventscalendar”).wijevcal({
dataStorage: {
loadEvents: function (visibleCalendars, successCallback, errorCallback) {
var url = ‘index.php?option=com_calendar&controller=calendar&task=load_calendars’;
$.ajax(url, {
dataType: ‘JSON’,
success: function (data) {
//IS THIS CORRECT
successCallback(data);
}
});
},
deleteCalendar: function (obj, successCallback, errorCallback) {
console.log(‘deleteCelendar’);
},
loadCalendars: function (successCallback, errorCallback) {
//IS THIS HOW YOU IMPLEMENT THIS ?
}
}
});
As you can see I am using jQuery’s ajax function to get the data from the server, But my implementation isn’t working so I think I am doing something wrong.
{“data”: {
“0A0A97CB-96E8-8CF7-7BC6-E96312452C98″: {
“id”: “0A0A97CB-96E8-8CF7-7BC6-E96312452C98″,
“calendar”: “Default”,
“subject”: “Fun Event”,
“location”: “San Francisco CA”,
“start”: 1335510000000,
“end”: 1335510000000,
“description”: “Going to MOMA with Katie”,
“color”: “default”,
“allday”: true,
“properties”: “{\”color\”:\”default\”,\”allday\”:true}”
}
}, “expires”: null}
Is the data I am returning wrong? is it possible for you to share some code snippets? | |
| Wijmo Team Member | abdiasm posted on May 1, 2012 at 12:27 pm Hi orchid1, I apologize for the delay. I’m working on your issue with the concerned team on loading data from an external source in the EventsCalendar. I’ll update you as soon as we figure out something. Best Regards | Answer |
| Wijmo Team Member | dmitrim posted on May 1, 2012 at 3:15 pm Hi,
$(“#eventscalendar”).wijevcal({
visibleCalendars: ["My", "Work"],
dataStorage: {
addEvent: _updateEvent,
updateEvent: _updateEvent,
deleteEvent: function (obj, successCallback, errorCallback) {
window.setTimeout(function () {
var curCalStore = amplify.store(“calendarstore_” + obj.calendar);
if (!curCalStore) {
curCalStore = {};
}
if (curCalStore[obj.id]) {
delete curCalStore[obj.id];
}
amplify.store(“calendarstore_” + obj.calendar, curCalStore);
successCallback()
}, 400); //simulate server delay
//errorCallback(“Unable to delete event”);
},
loadEvents: function (visibleCalendars,
successCallback, errorCallback) {
var i, j, events = [];
window.setTimeout(function () {
for (i = 0; i < visibleCalendars.length; i++) {
var curCalStore = amplify.store(“calendarstore_” + visibleCalendars[i]);
if (!curCalStore) {
curCalStore = {};
amplify.store(“calendarstore_” + visibleCalendars[i], curCalStore);
}
for (j in curCalStore) {
events.push(curCalStore[j]);
}
}
successCallback(events);
}, 500);
//errorCallback(“unable to load events”);
},
addCalendar: _updateCalendar,
updateCalendar: _updateCalendar,
deleteCalendar: function (obj, successCallback, errorCallback) {
successCallback();
//errorCallback(“Unable to delete calendar”);
},
loadCalendars: function (successCallback, errorCallback) {
var calendars = [{ name: "My", id: "My", color: "red" },
{ name: "Work", id: "Work", color: "blue"}];
successCallback(calendars);
}
}
});
Please, let me know if you have any other questions. | Answer |
| Wijmo Team Member | dmitrim posted on May 1, 2012 at 3:17 pm In your code you have object. You need pass data like this(as array): [{ | Answer |
| Wijmo Team Member | orchid1 posted on May 1, 2012 at 3:31 pm I traced some of the code in the the example and I got pretty far on it. I saw in one of the examples that it is indeed an array, I should have looked more closely at the examples I kinda felt like a fool. Anyways I do appreciate you posting back, this clarifies things a lot more. | Answer |
| Wijmo Team Member | orchid1 posted on May 2, 2012 at 6:43 am OK I am really grasping this now, the examples above clarify some things a bit more. That and I found the examples in the “examples” folder plus the regular docs.Thanks very much. | Answer |
| Wijmo Team Member | Answer |
Tagged: Custom Data Store, Events Calendar
You must be logged in to reply to this topic.