-
18 Dec 2012 11:03 PM #1
keyup override function not work
keyup override function not work
hello all
this is my code :in this code keyup( keyup: function(e)) not work and any action
my extjs version is 4.1
Code:Ext.require([ '*' ]); Ext.Loader.setPath('Ext.ux', '/extjs/examples/ux'); Ext.onReady(function() { console.log('hi'); Ext.define('User', { extend: 'Ext.data.Model', fields: ['id', 'name', 'email'] }); var myStore = Ext.create('Ext.data.Store', { model: 'User', proxy: { type: 'ajax', url : '/cloud/GetdataXml', reader: { type: 'xml', record:'user', root: 'users' } } }); myStore.load(); console.log('hi2'); var grid=Ext.create('Ext.grid.Panel', { store:myStore , columns:[{ dataIndex: 'id', width: 50, text: 'ID' },{ dataIndex: 'name', width: 100, text: 'name' },{ dataIndex: 'email', width: 150, text: 'Address' }]/*, plugins:[{ ptype: 'rowexpander', rowBodyTpl : [ '<p>{email}</p>' ] }]*/, height: 400, width: 400 }); console.log('hi3'); var form=Ext.create('Ext.form.Panel', { title: 'User Form', height: 450, width: 500, bodyPadding: 10, defaultType: 'textfield', items: [ { fieldLabel: 'Search', name: 'query', allowBlank:true , listeners: { // call this function on event keyup keyup: function(e) { alert("hello from keyup"); var theQuery=e.getValue(); console.log('keyup'+theQuery); } } }, { xtype: 'textfield', name: 'name', fieldLabel: 'Name', allowBlank: true // requires a non-empty value }, grid ], renderTo:'results' }); Ext.override(Ext.form.Field, { onKeyUp : function(e) { this.fireEvent('keyup', this, this); }, fireKey : function(e) { if(((Ext.isIE && e.type == 'keydown') || e.type == 'keypress') && e.isSpecialKey()) { this.fireEvent('specialkey', this, e); console.log('fireKey'); } else { this.fireEvent(e.type, this, e); console.log('else'); } } , initEvents : function() { this.el.on("focus", this.onFocus, this); this.el.on("blur", this.onBlur, this); this.el.on("keydown", this.fireKey, this); this.el.on("keypress", this.fireKey, this); this.el.on("keyup", this.fireKey, this); this.originalValue = this.getValue(); } }); form.show() });
-
20 Dec 2012 11:05 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,599
- Vote Rating
- 434
Set enableKeyEvents to true on the field.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
29 Dec 2012 7:36 AM #3
not work
not work
this code not work keyup override and not any action
Code:Ext.require([ '*' ]); Ext.Loader.setPath('Ext.ux', '/extjs/examples/ux'); Ext.onReady(function() { console.log('hi'); Ext.define('User', { extend: 'Ext.data.Model', fields: ['id', 'name', 'email'] }); var myStore = Ext.create('Ext.data.Store', { model: 'User', proxy: { type: 'ajax', url : '/cloud/GetdataXml', reader: { type: 'xml', record:'user', root: 'users' } } }); myStore.load(); console.log('hi2'); var grid=Ext.create('Ext.grid.Panel', { store:myStore , columns:[{ dataIndex: 'id', width: 50, text: 'ID' },{ dataIndex: 'name', width: 100, text: 'name' },{ dataIndex: 'email', width: 150, text: 'Address' }], height: 400, width: 400 }); console.log('hi3'); var form=Ext.create('Ext.form.Panel', { title: 'User Form', height: 450, width: 500, bodyPadding: 10, defaultType: 'textfield', items: [ { enableKeyEvents: true, fieldLabel: 'Search', name: 'query', allowBlank:true , listeners: { // call this function on event keyup keyup: function(e) { console.log('keyup up'); var theQuery=e.getValue(); console.log('keyup'+theQuery); } } }, { xtype: 'textfield', name: 'name', fieldLabel: 'Name', allowBlank: true // requires a non-empty value }, grid ], renderTo:'results' }); Ext.override(Ext.form.Field, { onKeyUp : function(e) { this.fireEvent('keyup', this, this); }, fireKey : function(e) { if(((Ext.isIE && e.type == 'keydown') || e.type == 'keypress') && e.isSpecialKey()) { this.fireEvent('specialkey', this, e); console.log('fireKey'); } else { this.fireEvent(e.type, this, e); console.log('else'); } } , initEvents : function() { this.el.on("focus", this.onFocus, this); this.el.on("blur", this.onBlur, this); this.el.on("keydown", this.fireKey, this); this.el.on("keypress", this.fireKey, this); this.el.on("keyup", this.fireKey, this); this.originalValue = this.getValue(); } }); form.show() });
-
29 Dec 2012 8:32 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,599
- Vote Rating
- 434
This worked just fine:
Code:{ xtype : 'textfield', fieldLabel : 'test', enableKeyEvents : true, listeners : { keyup : function(field, e) { console.log(field.getValue()); } } }Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.


Reply With Quote