Custom Cell Content

Dynamically customize the cell content of the timeline by showing event-related icons, visual indicators, and a quick add button directly in each cell.

This is achieved using the renderCell function, where event data in each cell is used to display icons based on the event, a badge showing total event hours, and a button to quickly add new events. The add event icon is dynamically added during onCellHoverIn. An event cap per cell is implemented by reading the event count from onCellHoverIn args and enforcing it in onEventCreate, blocking event creation by returning false. This approach helps visualize workload per day and enables quick actions, making scheduling more efficient and user-friendly.

In this demo, cells represent a day. Depending on the resolution, they can also stand for a week, month, or more, while remaining fully customizable. See this configuration demo to try out different timeline resolution settings.

Download and try example

Demo

Loading the live demo

Preview in full screen

Add workload badges, status icons, and a hover quick-add button to each Timeline cell — and cap events per cell.

Code

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

var myEvents = [
  {
    id: 1,
    resource: 1,
    title: 'Review',
    start: '2026-11-01T00:00',
    end: '2026-11-01T02:00',
  },
  {
    id: 2,
    resource: 1,
    title: 'Demo',
    start: '2026-11-01T00:00',
    end: '2026-11-01T02:00',
  },
  {
    id: 3,
    resource: 1,
    title: 'Kickoff',
    start: '2026-11-01T00:00',
    end: '2026-11-01T02:00',
  },
  {
    id: 4,
    resource: 4,
    title: 'Strategy',
    start: '2026-11-01T00:00',
    end: '2026-11-01T02:00',
  },
  {
    id: 5,
    resource: 4,
    title: 'Collab',
    start: '2026-11-01T00:00',
    end: '2026-11-01T02:00',
  },
  // Showing partial data. Download full source.
];

var myResources = [
  { id: 1, name: 'Resource A' },
  { id: 2, name: 'Resource B' },
  { id: 3, name: 'Resource C' },
  { id: 4, name: 'Resource D' },
];

var hoveredDate;
var hoveredResource;
var hoveredCellEventCount;

var iconMap = {
  Review: 'calendar',
  Demo: 'play',
  Kickoff: 'flag',
  Strategy: 'map',
  Collab: 'bubbles',
  Update: 'upload',
  Discussion: 'bubble',
  Planning: 'pencil',
  Retrospect: 'history',
  Onboard: 'user4',
};
var titles = Object.keys(iconMap);

var calendar = mobiscroll.eventcalendar('#demo-cell-content', {
  clickToCreate: false,
  dragToCreate: false,
  dragToMove: false,
  dragToResize: false,
  extendDefaultEvent: function (args) {
    return {
      title: titles[Math.floor(Math.random() * titles.length)],
      end: new Date(args.start.getTime() + 2 * 3600000),
    };
  },
  cssClass: 'mds-timeline-cell-content',
  view: {
    timeline: {
      endDay: 5,
      eventDisplay: 'fill',
      type: 'month',
      resolutionHorizontal: 'day',
      startDay: 1,
    },
  },
  renderCell: function (args) {
    var events = args.events;
    var hours = Math.round(
      events.reduce(function (s, ev) {
        return s + (new Date(ev.end) - new Date(ev.start)) / 36e5;
      }, 0),
    );
    var classMap = { 2: 'light', 4: 'medium', 6: 'semi', 8: 'full' };
    var colorClass = 'mds-timeline-cell-content-badge-' + (classMap[hours] || 'default');

    var iconHtml = '';
    var addedIcons = new Set();

    for (var i = 0; i < events.length; i++) {
      var ev = events[i];
      var iconName = iconMap[ev.title];
      if (iconName && !addedIcons.has(ev.title)) {
        iconHtml += '<i class="mbsc-font-icon mbsc-icon-' + iconName + ' mds-timeline-cell-icon" title="' + ev.title + '"></i>';
        addedIcons.add(ev.title);
      }
    }

    return (
      '<div class="mds-timeline-cell-content-badge ' +
      colorClass +
      '">' +
      hours +
      'h / 8h</div>' +
      '<button class="mds-timeline-cell-content-add">+</button>' +
      '<div class="mds-timeline-cell-icons">' +
      iconHtml +
      '</div>'
    );
  },
  renderTimelineEventContent: function (event) {
    var hours = Math.round((event.endDate - event.startDate) / 36e5);
    return '<div>' + event.title + ' - ' + hours + 'h</div>';
  },
  onCellHoverIn: function (args) {
    hoveredDate = args.date;
    hoveredResource = args.resource.id;
    hoveredCellEventCount = args.events.length;
  },
  onEventCreate: function () {
    if (hoveredCellEventCount >= 4) {
      mobiscroll.toast({
        message: 'Task limit reached',
      });
      return false;
    }
  },
  data: myEvents,
  resources: myResources,
});

document.addEventListener('click', function (e) {
  if (e.target.closest('.mds-timeline-cell-content-add')) {
    if (!hoveredDate || !hoveredResource) {
      return;
    }

    if (hoveredCellEventCount >= 4) {
      mobiscroll.toast({
        message: 'Task limit reached',
      });
      return;
    }

    calendar.addEvent({
      start: hoveredDate,
      end: new Date(hoveredDate.getTime() + 2 * 3600000),
      resource: hoveredResource,
      title: titles[Math.floor(Math.random() * titles.length)],
    });

    hoveredCellEventCount++;
  }
});
  

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.