Our pure JavaScript Scheduler component


Post by andrew.perera »

As part of the Bryntum Scheduler Pro upgrader from Bryntum Scheduler, we had to remove the 'eventBodyTemplate'. We have a way to render events based on the business requirement.

  eventBodyTemplate: (values) =>
    values &&
    values
      .map(
        (value) =>
          `<div class="allocated-events" style="${value.eventColor} ${
            value.bookingStyle
          } left: ${value.left}px;width: ${value.width - 4}px"> ${
            value.iconInfo
          } ${value.name}</div>`
      )
      .join(''),

This is what the code looks like. However, as per the documentation, I tried to return the same value in the 'eventRenderer' and all I could see empty events now.

  eventRenderer({ eventRecord, renderData }) {
    renderData.eventColor = '';
    renderData.eventStyle = 'hollow';
    renderData.style = `${eventRecord.data.eventStyle}`;
    // getCoordinateFromDate gives us a px value in time axis, subtract events left from it to be within the event
    const dateToPx = (date) =>
      this.getCoordinateFromDate(date) - renderData.left;
    // Calculate coordinates for all nested events and put in an array passed on to eventBodyTemplate
    console.log('before');
    if (!eventRecord.data.nestedBookingEvents) return [];
    console.log('After');
    const newValues = eventRecord.data.nestedBookingEvents.map(
      (nestedEvent) => ({
        left: dateToPx(
          addMilliseconds(eventRecord.data.startDate, nestedEvent.startOffset)
        ),
        width: dateToPx(
          addMilliseconds(eventRecord.data.startDate, nestedEvent.endOffset)
        ),
        name: eventRecord.data.name,
        bookingStyle: nestedEvent.bookingStyle ? nestedEvent.bookingStyle : '',
        iconInfo: getNestedEventIcon(eventRecord.data, nestedEvent),
        eventColor: getNestedBookingColor(eventRecord.data, nestedEvent),
      })
    );
    console.log(newValues);
    console.log('^newValues');
    let newTemplate = '';
    newTemplate =
      newValues &&
      newValues
        .map(
          (value) =>
            StringHelper.xss`<div class="allocated-events" style="${
              value.eventColor
            } ${value.bookingStyle} left: ${value.left}px;width: ${
              value.width - 4
            }px"> ${value.iconInfo} ${value.name}</div>`
        )
        .join('');
    console.log(newTemplate);
    console.log('^newTemplate');
    return newTemplate;
  },

This is how the new event render looks like now. Could you please assist us? This is a functionality that is heavily used in our scheduler. Thanks.


Post by tasnim »

Hi,

Can't see any image though, Could you please try re-attaching it? And how can we reproduce it?


Post by andrew.perera »

emptyevents.png
emptyevents.png (49.11 KiB) Viewed 88 times

Post by tasnim »

Hi,

Thanks for sharing the image. Are you able to reproduce it with our online demos here https://bryntum.com/products/schedulerpro/examples/? If you can, could you please share the demo link and the steps to follow to reproduce the issue?

If you can't, would it be possible for you to upload a runnable test case so we can download/reproduce and debug it?


Post Reply