Search code examples
javascriptfullcalendarfullcalendar-scheduler

FullCalendar Scheduler Events are not showing in TimelineView


I have created a scheduler with following events and resources

var sampleEvents = [{   'id': '1',
                        'resourceid': '27', 
                        'start': '2018-09-19T07:00:00',
                        'stop': '2018-09-19T16:00:00',
                        'title': 'Message 1',
                    }];

var sampleResources = [{
                        facility_type: "Message Type", 
                        id: '27', 
                        title: "Message 1"
                      }];

$('#calendar').fullCalendar({
                                schedulerLicenseKey: 'CC-Attribution-NonCommercial-NoDerivatives',
                                now: currenDate //Today's Date,
                                editable: false,
                                header: {
                                  left: 'today prev,next',
                                  center: 'title',
                                  right: 'month,timelineDay,agendaWeek'
                                },
                                defaultView: 'month',
                                resourceGroupField: 'facility_type',
                                resourceColumns: [
                                    {
                                        labelText: 'Facility',
                                        field: 'title',
                                        width: 150,
                                    },
                                ],
                                resources: sampleEvents,
                                events: sampleResources,
                                dayClick: function(date, jsEvent, view) {
                                  if(view.name == 'month' || view.name == 'basicWeek') {
                                    $('#calendar').fullCalendar('changeView', 'timelineDay');
                                    $('#calendar').fullCalendar('gotoDate', date);
                                  }
                                },
                              });

                            }, function (error) {

                        });

The events are showing in month view, but they are not shown in day view. Can someone tell me where the problem is?


Solution

  • In JavaScript, variable and property names are case-sensitive. Therefore

    'resourceid': '27'` 
    

    should be

    'resourceId': '27'
    

    as per the example in the documentation. The event isn't showing the timeline view because as far as fullCalendar is concerned you didn't tell it which resource to associate it with.