Search code examples
fullcalendarfullcalendar-scheduler

Adding hours in each columns in fullcalendar.js


I would like to add the time into each cell of fullcalendar, regardless the number of ressources I have.

I don't really know how to process. I uploaded a picture with what I would like.

Thanks a lot!

What I have

What I would like


Solution

  • Found it! The idea is to add background events. "15" is your timeslot, in the following example with 60 minutes

    in event function add (with arbitrary star_day and end_day)

     events: function(start, end, timezone, callback) {
       var timeCursor = moment(start_day);
       while (timeCursor < moment(end_day))
       {
         events.push({
          start: timeCursor.toISOString(),
          color:"inherit",
          title:timeCursor.utc().format("HH:mm"),
          end: timeCursor.add('15', 'minutes').toISOString(),
          rendering: 'background'
          });
        }
      }
    

    in eventRender function add:

    eventRender: function(event, element, view) {
     if (event.rendering == 'background') {
      element.append(event.title);
      }
     }
    

    Here is the result (with 60 minutes):

    enter image description here