0

Im trying to get the events from the Scheduler but cant seem to do so. By looking at their documentation I found that I needed to implement SchedulerEventSupport. I implemented it like this:

        var agendaView = new Y.SchedulerAgendaView();
        var dayView = new Y.SchedulerDayView();
        var eventRecorder = new Y.SchedulerEventRecorder();
        //global variable
        eventSupport = new Y.SchedulerEventSupport();
        var monthView = new Y.SchedulerMonthView();
        var weekView = new Y.SchedulerWeekView();

        schedule = new Y.Scheduler(
          {
            activeView: weekView,
            boundingBox: '#myScheduler',
            date: new Date(2013, 1, 4),
            eventRecorder: eventRecorder,
            items: events,
            render: true,
            eventSupport: eventSupport,
            views: [dayView, weekView, monthView, agendaView]
          }
        );

        function displayEvents(){
            console.log(eventSupport.getEvents());
        }

Everytime I run displayEvents() I get this error TypeError: Cannot read property 'sort' of undefined.

How Can I display the events saved in scheduler?

Abdul Mirza
  • 23
  • 2
  • 9
  • Can you use [`scheduler.getEvents()`](http://alloyui.com/api/classes/A.SchedulerBase.html#method_getEvents)? – stiemannkj1 Mar 10 '17 at 15:10
  • Yeah that works. Thanks – Abdul Mirza Mar 11 '17 at 19:43
  • Do you know how I could remove the timezone from the dates? – Abdul Mirza Mar 11 '17 at 20:02
  • Great! Please accept and upvote my answer. `schedule.getEvents()[index].get('startDate')` and `get('endDate')` allow you to obtain the JavaScript `Date` objects. [JavaScript `Date` objects always use the user's timezone](http://stackoverflow.com/questions/15141762/how-to-initialize-javascript-date-to-a-particular-timezone#15171030), so you cannot separate the `Date` from the timezone. You can, however, get the `Date` in the GMT timezone: http://stackoverflow.com/questions/8945029/converting-date-to-gmt-0 – stiemannkj1 Mar 11 '17 at 23:17

1 Answers1

0

Use Scheduler.getEvents():

function displayEvents(){
    console.log(schedule.getEvents());
}
stiemannkj1
  • 4,418
  • 3
  • 25
  • 45