Request new features or modifications


Post by dhettinger »

Hello,
I have noticed that when rendering very wide tall horizontal schedules with hundreds of events IE 9, 10 freeze for a long running script after the events come to view where it looks like it's drawing the vertical lines (after setting timespan). I was able to identify the function in the sch-all-debug file that it was spending all the time in (sometimes 30 seconds) and fix the issue.

I would really rather avoid having modified source code so I was wondering if you could take a look and possibly implement this fix in a release at some point.

Original method getElementData line 11024 (2.2.12)
getElementData : function(viewStart, viewEnd, records) {
        var s = this.store,
            scheduler = this.schedulerView,
            isHorizontal = scheduler.isHorizontal(),
            rs = records || s.getRange(),
            data = [],
            record, date, region, templateData;

        for (var i = 0, l = rs.length; i < l; i++) {
            record = rs[i];
            date = record.get('Date');
            templateData = this.getTemplateData(record);

            if (date && Sch.util.Date.betweenLesser(date, viewStart, viewEnd)) {
                region = scheduler.getTimeSpanRegion(date, null, this.expandToFitView);

                data.push(Ext.apply({
                    id      : this.getElementId(record),
                    // using $cls to avoid possible conflict with "Cls" field in the record
                    // `getElementCls` will append the "Cls" field value to the class
                    $cls    : this.getElementCls(record, templateData),
                    left    : region.left,
                    top     : region.top,
                    width   : isHorizontal ? 1 : region.right - region.left,
                    height  : isHorizontal ? Ext.versions.touch ? '100%' : region.bottom - region.top : 1
                }, templateData));
            }
        }
        
        return data;
    },
I found that this line was taking up a lot of unnecessary time:
region = scheduler.getTimeSpanRegion(date, null, this.expandToFitView);

This method was very slow and very unnecessary, since it's doing a lot of comparisions with date and null.
Here is the method I replaced it with (removing some stuff out of the for loop since the height won't change)
getElementData : function(viewStart, viewEnd, records) {
		var s = this.store,
			scheduler = this.schedulerView,
			isHorizontal = scheduler.isHorizontal(),
			rs = records || s.getRange(),
			data = [],
			height = 0,
			isSchedulerReady = false,
			record, date, templateData;
		
		if (scheduler.orientation && scheduler[scheduler.orientation].view && scheduler[scheduler.orientation].view.getTableRegion()) {
			var tableRegion = scheduler[scheduler.orientation].view.getTableRegion();
			height = tableRegion.bottom - tableRegion.top;
			
			if (this.expandToFitView) {
				height = Math.max(height, scheduler[scheduler.orientation].view.getEl().dom.clientHeight); // fallback in case grid is not rendered (no rows/table)
			}
			
			isSchedulerReady = true;
		}

		for (var i = 0, l = rs.length; i < l; i++) {
			record = rs[i];
			date = record.get('Date');
			templateData = this.getTemplateData(record);

			if (date && Sch.util.Date.betweenLesser(date, viewStart, viewEnd)) {
				var left = 0;
				if (isSchedulerReady) {
					left = scheduler[scheduler.orientation].view.getXFromDate(date);
				}
				data.push(Ext.apply({
							id: this.getElementId(record),
							// using $cls to avoid possible conflict with "Cls" field in the record
							// `getElementCls` will append the "Cls" field value to the class
							$cls: this.getElementCls(record, templateData),
							left: left,
							top: 0,
							width: isHorizontal ? 1 : 0,
							height: isHorizontal ? Ext.versions.touch ? '100%' : height : 1
				}, templateData));
			}
		}
		
		return data;
	},
Feel free to change it however you want all I know is the schedule draws instantly now and still draws all lines correctly.

Post by mats »

Yes, that's a very inefficient method. Thanks for pointing it out, will get it fixed shortly. Ticket:

https://www.assembla.com/spaces/bryntum ... ity/ticket:

Post Reply