简体   繁体   中英

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?

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.

Assigned objects are improper. If you pass the correct objects. It will work fine

resources: sampleResources,
 events: sampleEvents

You can refer below working jsfiddle link

http://jsfiddle.net/jso51pm6/3769/
                            resources: sampleEvents,
                            events: sampleResources,

You filled them wrong. Switch them. It will work.

                            resources: sampleResources,
                            events: sampleEvents,

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM