1. #1
    Sencha User
    Join Date
    Mar 2012
    Posts
    7
    Vote Rating
    0
    ehsanlinux is on a distinguished road

      0  

    Default 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()
    });

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,599
    Vote Rating
    434
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    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.

  3. #3
    Sencha User
    Join Date
    Mar 2012
    Posts
    7
    Vote Rating
    0
    ehsanlinux is on a distinguished road

      0  

    Default 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()
    });

  4. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,599
    Vote Rating
    434
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    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.