Listening RowEdit plugin in controller

By Vitaliy on June 23, 2012. ExtJS 4.1.0
2646
Reply to thread

Js Code

Ext.define('App.controller.Main', {
    extend: 'Ext.app.Controller',
    views: ['user.List'],
    stores: ['Users'],
    init: function () {
        this.control({
            'userlist': {
                render: function () { this.log('render'); },
                //plugin events
                beforeedit: function () { this.log('beforeedit'); },
                edit: function () { this.log('edit'); },
                validateedit: function () { this.log('validateedit'); }
            }
        });
    },
    log: function (msg) {
        Ext.get('log').createChild({
            tag: 'div',
            html: Ext.String.format('{0} {1}', Ext.Date.format(new Date(), 'g:i:s:ms'), msg)
        });
    }
});    

How To Add Custom Events To Ext Component

By Vitaliy on April 26, 2012. ExtJS 3.4.0
2864
Reply to thread

Js Code

MyApp.customMenu = Ext.extend(Ext.menu.Menu, {
	constructor: function (config) {
		config = config || {};
		MyApp.customMenu.superclass.constructor.call(this, Ext.apply(config, {
			items: [
				{ text: 'New File...' },
				{ text: 'New Project...' }
			]
		}));
		//You can add custom events in constructor
		this.addEvents('newfile');
	},
	initComponent: function () {
		MyApp.customMenu.superclass.initComponent.apply(this, arguments);
		//You can add custom events in initComponent
		this.addEvents('newproject');
		this.on('itemclick', this.onItemClick, this);
	},
	onItemClick: function (item, e) {
		switch (item.text) {
			case 'New File...': this.fireEvent('newfile'); break;
			case 'New Project...': this.fireEvent('newproject'); break;
		}
	}
});