Event rendering problem

Hi,

I’ve a problem when adding a lot of events in the scheduler.

As you can see in the sample provided as attachment, the event at 10:30 is rendered outside 9 April holder.

Is there a way to avoid this ?

Thanks.
scheduler_test.zip (104 KB)

Hello,

Thank you very much for providing sample where this issue could be checked!
This issue is fixed in the current dev version.
Updated function:

[code]scheduler._pre_render_events_line=function(evs,hold){
evs.sort(function(a,b){
if(a.start_date.valueOf()==b.start_date.valueOf())
return a.id>b.id?1:-1;
return a.start_date>b.start_date?1:-1;
});
var days=[]; //events by weeks
var evs_originals = [];

this._min_mapped_duration = Math.ceil(this.xy.min_event_height * 60 / this.config.hour_size_px);  // values could change along the way

for (var i=0; i < evs.length; i++) {
	var ev=evs[i];

    //check date overflow
    var sd = ev.start_date;
    var ed = ev.end_date;
	//check scale overflow
	var sh = sd.getHours();
	var eh = ed.getHours();
	
	ev._sday=this._get_event_sday(ev); // sday based on event start_date
	if (!days[ev._sday]) days[ev._sday]=[];
	
	if (!hold){
		ev._inner=false;

        var stack=days[ev._sday];

        while (stack.length) {
            var t_ev = stack[stack.length-1];
            var t_end_date = this._get_event_mapped_end_date(t_ev);
            if (t_end_date.valueOf() <= ev.start_date.valueOf()) {
                stack.splice(stack.length-1,1);
            } else {
                break;
            }
        }

        var sorderSet = false;
        for(var j=0; j<stack.length; j++){
            var t_ev = stack[j];
            var t_end_date = this._get_event_mapped_end_date(t_ev);
            if(t_end_date.valueOf()<=ev.start_date.valueOf()){
                sorderSet = true;
                ev._sorder=t_ev._sorder;
                stack.splice(j,1);
                ev._inner=true;
                break;
            }
        }

        if (stack.length)
            stack[stack.length-1]._inner=true;


        if (!sorderSet) {
            if (stack.length) {
                if (stack.length <= stack[stack.length - 1]._sorder) {
                    if (!stack[stack.length - 1]._sorder)
                        ev._sorder = 0;
                    else
                        for (j = 0; j < stack.length; j++) {
                            var _is_sorder = false;
                            for (var k = 0; k < stack.length; k++) {
                                if (stack[k]._sorder == j) {
                                    _is_sorder = true;
                                    break;
                                }
                            }
                            if (!_is_sorder) {
                                ev._sorder = j;
                                break;
                            }
                        }
                    ev._inner = true;
                }
                else {
                    var _max_sorder = stack[0]._sorder;
                    for (j = 1; j < stack.length; j++)
                        if (stack[j]._sorder > _max_sorder)
                            _max_sorder = stack[j]._sorder;
                    ev._sorder = _max_sorder + 1;
                    ev._inner = false;
                }

            }
            else
                ev._sorder = 0;
        }

		stack.push(ev);            

        if (stack.length>(stack.max_count||0)) {
            stack.max_count=stack.length;
            ev._count=stack.length;
        }
        else {
            ev._count=(ev._count)?ev._count:1;
        }
	}




	if ( sh < this.config.first_hour || eh >= this.config.last_hour ) {
        if(!ev._timed) { // timed events will handle originals and copies themself
            evs_originals.push(ev);
            evs[i]=ev=this._copy_event(ev);
        }
		if (sh < this.config.first_hour){
			ev.start_date.setHours(this.config.first_hour);
			ev.start_date.setMinutes(0);
		}
		if (eh >= this.config.last_hour){
			ev.end_date.setMinutes(0);
			ev.end_date.setHours(this.config.last_hour);
		}

		if (ev.start_date>ev.end_date || sh==this.config.last_hour) {
			evs.splice(i,1); i--; continue;
		}
	}
}
if (!hold){
	for (var i=0; i < evs.length; i++) {
        evs[i]._count = days[evs[i]._sday].max_count;
    }
	for (var i=0; i < evs_originals.length; i++)
		evs_originals[i]._count=days[evs_originals[i]._sday].max_count;
}

return evs;

};[/code]
Kind regards,
Ilya

Hi,

I’ve replaced the _pre_render_events_line function in my dhtmlxscheduler_debug.js file but it says the function ‘_get_event_mapped_end_date’ doesn’t exists.

Can you, if possible, give me that function ? or a link to the current dev version ?

Anyway, Thanks for your help :slight_smile:

scheduler._get_event_mapped_end_date = function(ev) { var end_date = ev.end_date; if (this.config.separate_short_events) { var ev_duration = (ev.end_date - ev.start_date)/60000; // minutes if (ev_duration < this._min_mapped_duration) { end_date = this.date.add(end_date, this._min_mapped_duration-ev_duration, "minute"); } } return end_date; };