We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 1847
    • 5 Posts
    Hi all,

    I am having one problem, using MODx CMPs and MODext. I am setting up a grid and I want to use listeners on it. I tried to use ’click’ and ’dblclick’ events for test, but it’s not working! I already posted this to Sencha forums (http://www.sencha.com/forum/showthread.php?133454-Listeners-not-working-on-grid&p=602105#post602105), but it seems like this problem is the question of MODx extension of ExtJS. Can anybody help me, please? I am attaching the code.

    /* GRID */
    Simpleshop.grid.ProductParam = function(config) {
        config = config || {};
        
        Ext.applyIf(config,{
            id: 'simpleshop-grid-product-param'
            ,url: Simpleshop.config.connectorUrl
            ,baseParams: { action: 'mgr/product/paramList', id: MODx.request['id'] }
            ,fields: ['param_id','param_label','param_output_modifier_label','param_required','value']
            ,paging: false
            ,remoteSort: false
            ,anchor: '97%'
            ,autoExpandColumn: 'param_name'
            ,columns: [{
                header: _('ss.field.name')
                ,xtype: 'templatecolumn'
                ,tpl: '{param_label} ({param_output_modifier_label})'
                ,sortable: false
                ,width: 100
            },{
                header: _('ss.field.required')
                ,xtype: 'booleancolumn'
                ,trueText: _('ss.truetext')
                ,falseText: _('ss.falsetext')
                ,dataIndex: 'param_required'
                ,sortable: false
                ,width: 30
                ,align: 'center'
            },{
                header: _('ss.field.value')
                ,dataIndex: 'value'
                ,sortable: false
                ,width: 150
                ,editor: { xtype: 'textfield' }
            }]
            ,listeners: {
                click: function(){ 
                    console.log('click'); // not working
                }, 
                dblclick: function(){ 
                    console.log('dblclick'); // not working
                } 
             }
            
        });
        
        
        Simpleshop.grid.ProductParam.superclass.constructor.call(this,config);
        
    };
    Ext.extend(Simpleshop.grid.ProductParam,MODx.grid.Grid,{
    
    
    });
    Ext.reg('simpleshop-grid-product-param',Simpleshop.grid.ProductParam);
    

      • 17499 ☆ A M B ☆
      • 872 Posts
      Try to bind your event after your constructor.

      Simpleshop.grid.ProductParam.superclass.constructor.call(this,config);
      
      this.on('click', function(){ console.log('click') }, this);
      
        • 1847
        • 5 Posts
        Thanks a lot! Now it’s working finally. smiley
          • 14951
          • 151 Posts
          I realize this is an old topic, but I'm finding that listeners don't seem to work almost anywhere without binding them after the constructor like @lossendae mentioned or adding them as such (again after the constructor):
          	this.addListener('render',function(){
          		console.log('rendered');
          	});


          Can anyone explain why this is? Is there any rhyme or reason to it?