ExtJS 4 MVC - How To Access Store From Controller?

By Vitaliy on March 24, 2012. ExtJS 4.0.7
3446
Reply to thread

Js Code

Ext.define('App.controller.Books', {
	extend: 'Ext.app.Controller',
	stores: ['Books'],
	init: function () {
		this.getBooksStore().loadData([
			{ id: 1, title: 'title 1', author: 'author 1' },
			{ id: 2, title: 'title 2', author: 'author 2' },
			{ id: 3, title: 'title 3', author: 'author 3' },
			{ id: 4, title: 'title 4', author: 'author 4' }
		]);
	}
});    

Scaling The Image By Mouse Wheel

By Vitaliy on March 22, 2012. ExtJS 4.0.7
2251
Reply to thread

Js Code

Ext.define('Ext.ux.ImgPreview', {
	extend: 'Ext.panel.Panel',
	layout: 'absolute',
	width: 100,
	height: 100,
	zoomDelta: 40,
	image: Ext.BLANK_IMAGE_URL,
	initComponent: function () {
		var image = Ext.widget('image', {
			xtype: 'image',
			width: this.width - 1,
			height: this.height - 1,
			src: this.image,
			x: 0,
			y: 0
		});

		this.on('afterrender', function () {
			var me = this,
				el = this.getEl(),
				zoomDelta = me.zoomDelta,
				delta,
				dx = Math.sqrt(Math.pow(zoomDelta, 2) + Math.pow(zoomDelta, 2)) / 2,
				imageEl = image.getEl(),
				imageBox;

			//first handler prevents page scrolling
			el.on('mousewheel', function (ev) { ev.stopEvent(); });
			//second handler is buffered
			el.on('mousewheel', function (ev) {
				delta = ev.getWheelDelta();
				imageBox = imageEl.getBox();

				imageEl.setBox({
					x: imageBox.x - delta * dx,
					y: imageBox.y - delta * dx,
					width: imageBox.width + delta * zoomDelta,
					height: imageBox.height + delta * zoomDelta
				}, false, { duration: 150 });
			}, this, { buffer: 50 });
		});

		this.items = [image];
		this.callParent(arguments);
	}
});    

Yesterday Date

By Vitaliy on March 16, 2012. ExtJS 4.0.7
2115
Reply to thread

Js Code

Ext.create('Ext.form.Panel', {
	title: 'Test Form',
	bodyPadding: 10,
	width: 300,
	items: [
		{
			xtype: 'datefield',
			fieldLabel: 'Yesterday',
			value: Ext.Date.add(new Date(), Ext.Date.DAY, -1)
		}
	],
	renderTo: 'output'
});