Mark Events instead of Creating Events

What is the best way to mark an event instead of showing it? I was experimenting by doing this in the view filter such as:

scheduler.filter_unit = function(ev_id, ev) {
  if (some_condition) return true;

  scheduler.markTimespan({
    start_date: ev.start_date,
    end_date: 	ev.end_date,
    sections: {unit: some_section}
  });
  return false;
}

This works nicely until a recurring event needs to be marked.

How should go about marking a recurring event?

You can iterate over scheduler._events to get recurring events. Each recurring event occurrence contains # in its id number.

I stumbled upon scheduler.getEvents(startDate, endDate) which easily narrows the events to selected dates and can be called in onBeforeViewChange.

Is there an event function which always fires rendering is complete?

When the page firsts loads the events happen in this order:

  • onBeforeViewChange
  • onViewChange
  • filter_unit
  • render
  • onXLE

When the view is changed, the events are called in this order:

  • onBeforeViewChange
  • filter_unit
  • render
  • onViewChange

In order for this to work, I need to put the scheduler.getEvents() logic to mark the events in onXLE and in onViewChange. This is ok, it works. Just wondering if there might be an onAfterViewChange or an event which always is fired after page rendering.

Also is there a way to get the start/end date of what’s currently being shown onscreen. I hacked together some logic which is working. If there’s some property which has the rendering start/end date I would rather use it instead of calculating it.

Why can’t you use onViewChange. It fires after updateView complete.

To get current scheduler dates you can using getState function and min_date and max_date properties.
docs.dhtmlx.com/scheduler/api__s … state.html

When the page is first loaded onViewChange fires before the data is loaded. If I check scheduler.getEvents() it will be empty.

onViewChange fires every time your view is changed (rendering completed). If you want to perform any action after data loading you should check onXLE docs.dhtmlx.com/scheduler/api__s … event.html .

The documentation is somewhat misleading:
“onViewChange fires every time your view is changed (rendering completed)”

If you load data, all the renderEvent() are called, the filter_unit() functions called and the onViewChange is NOT called.

Maybe one day, there might be an onAfterRender() event when is called after all of renderEvent() functions are called. In the meantime, I can use onXLE. So far, I can do everything I’ve needed to do through the APIs – a good sign that this is a great framework.