Event Rendering

Above the built in rendering mode you can either customize the full event or just the content of the event. If we break up the event into pieces there are six fields that we are interested in:

  • The event start and end time
  • Whether it is an allDay event or not
  • The event color
  • The event title
  • bufferBefore
  • bufferAfter

The scheduler takes care of positioning the event container and everything else is your responsibility. You will have to place and provide styling to all event fields. Beside the ones mentioned above you'll be able to render other custom fields, like description, location, participants ... and add buttons, custom interactions.

Pass a custom rendering function to the renderSchedulerEvent option. All original event fields along with computed fields like isMultiDay, lastDay can be reached inside the function.

The before/after buffers can help you visualise delays or added minutes for tasks. For example travel time for meetings/appointments, check in/check out for flights.

The buffers can be customized through the renderBufferBefore and renderBufferAfter options.

Download and try example

Demo

Loading the live demo

Preview in full screen

Render custom event cards in the Scheduler — add color stripes, labels, avatars, action buttons, and travel-time buffers.

Code

mobiscroll.setOptions({
  locale:  ,
  theme: ' ',
  themeVariant: ' '
});

var inst = mobiscroll.eventcalendar('#demo-customize-events', {
  clickToCreate:  ,
  dragToCreate:  ,
  dragToMove:  ,
  dragToResize:  ,
  eventDelete:  ,
  responsive: {
    xsmall: {
      view: {
        scheduler: {
          type: 'day',
        },
      },
    },
    medium: {
      view: {
        scheduler: {
          type: 'week',
        },
      },
    },
  },
  renderSchedulerEvent: function (data) {
    var cat = getCategory(data.original.category);
    if (data.allDay) {
      return '<div style="background:' + cat.color + '" class="md-custom-event-allday-title">' + data.title + '</div>';
    } else {
      return (
        '<div class="md-custom-event-cont" style="border-left: 5px solid ' +
        cat.color +
        ';background:' +
        cat.color +
        '">' +
        '<div class="md-custom-event-wrapper">' +
        '<div style="background:' +
        cat.color +
        '" class="md-custom-event-category">' +
        cat.name +
        '</div>' +
        '<div class="md-custom-event-details">' +
        '<div class="md-custom-event-title">' +
        data.title +
        '</div>' +
        '<div class="md-custom-event-time">' +
        data.start +
        ' - ' +
        data.end +
        '</div>' +
        '<button mbsc-button class="md-custom-event-btn" data-color="dark" data-variant="outline">Edit</button>' +
        '<div class="md-cutom-event-img-cont">' +
        getParticipants(data.original.participants) +
        '</div></div></div></div>'
      );
    }
  },
  renderBufferBefore: function (args) {
    var cat = getCategory(args.original.category);
    return (
      '<div class="md-schedule-buffer md-schedule-before-buffer">' +
      '<div class="md-schedule-buffer-background" ' +
      'style="background: repeating-linear-gradient(-45deg,#fcfffc,#fcfffc 10px,' +
      cat.color +
      ' 10px,' +
      cat.color +
      ' 20px)">' +
      '</div>' +
      '<span class="md-buffer-text">Travel time</span>' +
      '<span class="md-buffer-time">' +
      args.original.bufferBefore +
      ' minutes</span>' +
      '</div>'
    );
  },
  onEventClick: function (args) {
    if (args.domEvent.target.classList.contains('md-custom-event-btn')) {
      mobiscroll.toast({
        message: 'Edit clicked',
      });
    }
  },
});

function getCategory(id) {
  switch (id) {
    case 1:
      return {
        name: 'Project X',
        color: '#ff825d',
      };
    case 2:
      return {
        name: 'Stakeholder Mtg.',
        color: '#bd75d0',
      };
    case 3:
      return {
        name: 'Status Update',
        color: '#7f9230',
      };
    case 4:
      return {
        name: 'Information Sharing',
        color: '#f14590',
      };
    case 5:
      return {
        name: 'Team Building',
        color: '#64cad4',
      };
    default:
      return {
        name: 'No category',
        color: '#5ac8fa',
      };
  }
}

function getParticipants(ids) {
  var participants = '';
  if (ids) {
    for (var i = 0; i < ids.length; ++i) {
      participants += '<img class="md-custom-event-img" src="' + getParticipant(ids[i]).img + '"/>';
    }
  }
  return participants;
}

function getParticipant(id) {
  switch (id) {
    case 1:
      return {
        name: 'Lisa',
        img: 'https://img.mobiscroll.com/demos/f1.png',
      };
    case 2:
      return {
        name: 'Sharon',
        img: 'https://img.mobiscroll.com/demos/f2.png',
      };
    case 3:
      return {
        name: 'Emily',
        img: 'https://img.mobiscroll.com/demos/f3.png',
      };
    case 4:
      return {
        name: 'Rose',
        img: 'https://img.mobiscroll.com/demos/f4.png',
      };
    case 5:
      return {
        name: 'Matt',
        img: 'https://img.mobiscroll.com/demos/m1.png',
      };
    case 6:
      return {
        name: 'Rick',
        img: 'https://img.mobiscroll.com/demos/m2.png',
      };
    case 7:
      return {
        name: 'John',
        img: 'https://img.mobiscroll.com/demos/m3.png',
      };
    case 8:
      return {
        name: 'Ethan',
        img: 'https://img.mobiscroll.com/demos/m4.png',
      };
  }
}

mobiscroll.getJson(
  'https://trial.mobiscroll.com/multi-events/?vers=5',
  function (events) {
    inst.setEvents(events);
  },
  'jsonp',
);
  

Duplicate Session

You have signed in on a different machine. To keep everything in sync, you have been signed out of this session.

If you need to invite team members, manage seats and accounts you can do it from the licenses page.

Duplicate Session

We noticed you are logged in on a different machine and have closed your old session.

If you need to invite team members, manage seats and accounts you can do it from the licenses page.