1 min read

The new Sch.plugin.HeaderZoom plugin for easy zooming

We have just released Ext Scheduler 2.2.17 which includes a plugin called “Sch.plugin.HeaderZoom”. This allows you to very quickly zoom […]

We strive to keep posts updated, but code samples may sometimes be outdated. Humans, see the Bryntum documentation; agents, https://mcp.bryntum.com for the latest info.

We have just released Ext Scheduler 2.2.17 which includes a plugin called “Sch.plugin.HeaderZoom”. This allows you to very quickly zoom in to a selected time span by using drag and drop. The plugin itself is extremely simple, and the full source can be seen below.

[crayon striped=”false” lang=”js” nums=”false” toolbar=”false”]
Ext.define(“Sch.plugin.HeaderZoom”, {
extend : “Sch.util.DragTracker”,
mixins : [ ‘Ext.AbstractPlugin’ ],
alias : ‘plugin.scheduler_headerzoom’,
lockableScope : ‘top’,

scheduler : null,
proxy : null,
headerRegion : null,

init : function (scheduler) {
scheduler.on({
destroy : this.onSchedulerDestroy,
scope : this
});

this.scheduler = scheduler;

scheduler.down(‘timeaxiscolumn’).on({
afterrender : this.onTimeAxisColumnRender,
scope : this
});
},

onTimeAxisColumnRender : function (column) {
this.proxy = column.el.createChild({ cls : ‘sch-drag-selector’ });

this.initEl(column.el);
},

onStart : function (e) {
this.proxy.show();

this.headerRegion = this.scheduler.normalGrid.headerCt.getRegion();
},

onDrag : function (e) {
var headerRegion = this.headerRegion;
var dragRegion = this.getRegion().constrainTo(headerRegion);

dragRegion.top = headerRegion.top;
dragRegion.bottom = headerRegion.bottom;

this.proxy.setRegion(dragRegion);
},

onEnd : function (e) {
if (this.proxy) {
this.proxy.setDisplayed(false);

var scheduler = this.scheduler;
var timeAxis = scheduler.timeAxis;
var region = this.getRegion();
var unit = scheduler.getSchedulingView().timeAxisViewModel.getBottomHeader().unit;
var range = scheduler.getSchedulingView().getStartEndDatesFromRegion(region);

scheduler.zoomToSpan({
start : timeAxis.floorDate(range.start, false, unit, 1),
end : timeAxis.ceilDate(range.end, false, unit, 1)
});
}
},

onSchedulerDestroy : function () {
if (this.proxy) {
Ext.destroy(this.proxy);

this.proxy = null;
}

this.destroy();
}
});
[/crayon]

Using it in your SchedulerPanel is as easy as doing:

[crayon striped=”false” lang=”js” nums=”false” toolbar=”false”]
var scheduler = new Sch.panel.SchedulerGrid({
plugins : [
new Sch.plugin.HeaderZoom()
]
});
[/crayon]

Instead of describing what it does, here’s a short demo video showing it in action. You can also try it out live here. We hope you’ll find it a useful addition to our codebase.

[youtube id=”uKGwxCue3BU” width=”550″ height=”300″]

Mats Bryntse

Mats Bryntse is the founder and CEO of Bryntum, where he leads the team building advanced scheduling and project planning components for the web. He has spent the past 15 years focused on component performance, developer experience, and making complex user interfaces feel simple. Bryntum's components cover Gantt charts, data grids, calendars, schedulers, and Kanban boards, and Mats works across all of them, from API design to the details of rendering large data sets in the browser. Away from work he plays chess and badminton.

Ext Scheduler

Try Bryntum components

Fast, framework-agnostic UI components for scheduling and project management.

Start a free trial

Related posts