Unit View - Display Event Count


#1

Is there a way to display the number of events for each unit on the unit view column headers?
Please help us out with the code snippet on how to implement that.


#2

Hi,

You can implement it using unit_scale_text template. Get events in the active view and check their section_id value:

scheduler.templates.unit_scale_text = function(key, label, unit) {
	var evs = scheduler.getEvents(scheduler.getState().min_date, scheduler.getState().max_date); 
	var count = 0;
  	for (var i=0; i<evs.length; i++){
       if(evs[i].section_id == key)
         count++;
	}
	
    return label + ", events: "+count;
};

#3

Thanks Polina, We will try the solution you proposed and will let you know the result.

Regards,
Terence George