1. #1
    Sencha User
    Join Date
    Aug 2012
    Posts
    15
    Vote Rating
    0
    messyOne is on a distinguished road

      0  

    Default Unanswered: Add EventListener to a combobox

    Unanswered: Add EventListener to a combobox


    Hi guys,

    I have a PHP code which returns an JSON object. This object consists the data for a combobox. In my ExtJS script the object is embedded. Now I want to add a EventListener to this object, but I get the error "Uncaught TypeError: Object #<Object> has no method 'addListener'" if I try it with the addListerner.

    PHP array for JSON object
    PHP Code:
    $this->metadata['tbar']['combos'][] = array(    
      
    'Test',    
      array(        
        
    'hidden' => false,        
        
    'xtype' => 'combo',        
        
    'width' => 100,        
        
    'store' => $items,        
        
    'value' => $value,    
      )            
    ); 
    ExtJS panel create
    Code:
    Ext.create('widget.panel', {
                width: 1024,
                height: 728,
                renderTo: _this.config.config.dom,
                layout: 'fit',
                items: _this.panelItems,
                tbar : [
                    _this.config.metadata.tbar.combos,
                ]
            }); 
        }    
    }
    _this.config.metadata.tbar.combos is the JSON data for the combobox passed by PHP.

    How can I do it?

  2. #2
    Ext JS Premium Member tvanzoelen's Avatar
    Join Date
    Apr 2008
    Location
    Groningen - Netherlands
    Posts
    1,114
    Answers
    83
    Vote Rating
    30
    tvanzoelen has a spectacular aura about tvanzoelen has a spectacular aura about tvanzoelen has a spectacular aura about

      0  

    Default


    You can add it in the config of the combo. Because only afterrender of the combo you can set the listener.

    Code:
    $this->metadata['tbar']['combos'][] = array(    
      'Test',    
      array(        
        'hidden' => false,        
        'xtype' => 'combo',
        'listeners: '{ render: onComboboxRender }',        
        'width' => 100,        
        'store' => $items,        
        'value' => $value,    
      )            
    );
    and create that render function

    Code:
    onComboboxRender: function(c) {
        c.addListerner(yourlistener);
    }
    Or put all listeners directly in the config of you combo.

  3. #3
    Sencha User
    Join Date
    Aug 2012
    Posts
    15
    Vote Rating
    0
    messyOne is on a distinguished road

      0  

    Default


    Mhh... I have tried it, but no result.

    At first put the listener directly in combo:
    Code:
    $this->metadata['tbar']['combos'][] = array(
        $title,
        array(
            'hidden' => false,
            'xtype' => 'combo',
            'width' => 100,
            'store' => $items,
            'displayField' => 'display',
            'valueField' => 'value',
            'value' => $value,
            'listeners' => '{
                    select: function(combo, records, scope) {
                        console.log("foo");
                    }
                }'   
        )            
    );
    At second: In which position must the onComboboxRender be placed?

  4. #4
    Sencha Premium Member dawesi's Avatar
    Join Date
    Mar 2007
    Location
    Melbourne, Australia (aka GMT+10)
    Posts
    1,083
    Answers
    24
    Vote Rating
    44
    dawesi has a spectacular aura about dawesi has a spectacular aura about

      0  

    Default


    can you add the listener in the config object?

    Code:
    listeners : {
            change : function(myCombo,sel,orig){
                console.log('diff',Ext.Array.remove(myCombo.getValue(),myCombo.originalValue));
                myCombo.setValue(Ext.Array.remove(myCombo.getValue(),myCombo.originalValue));
                }
            }
    Teahouse Training Company
    Official Certified Sencha Trainer

    Australia / New Zealand / Singapore / Hong Kong & APAC



    SenchaWorld.com - Sencha webinars, videos, etc
    SenchaForge.org - (coming soon)
    TeahouseHQ.com - Sencha ecosystem training portal

    Code Validation : JSLint | JSONLint | JSONPLint

  5. #5
    Ext JS Premium Member tvanzoelen's Avatar
    Join Date
    Apr 2008
    Location
    Groningen - Netherlands
    Posts
    1,114
    Answers
    83
    Vote Rating
    30
    tvanzoelen has a spectacular aura about tvanzoelen has a spectacular aura about tvanzoelen has a spectacular aura about

      0  

    Default


    Hmm then this?

    Code:
    $this->metadata['tbar']['combos'][] = array(
        $title,
        array(
            'hidden' => false,
            'xtype' => 'combo',
            'width' => 100,
            'store' => $items,
            'displayField' => 'display',
            'valueField' => 'value',
            'value' => $value,
            'listeners' => '{
                    select: 
                      {
                          fn: function(combo, records, scope) {
                                console.log("foo");
                           }
                      }
                }'   
        )            
    );

  6. #6
    Sencha User
    Join Date
    Aug 2012
    Posts
    15
    Vote Rating
    0
    messyOne is on a distinguished road

      0  

    Default


    @tvanzoelen: Unfortunately it also doesn't work with this.

    @dawesi: The listener "change" also doesn't work.



  7. #7
    Ext JS Premium Member tvanzoelen's Avatar
    Join Date
    Apr 2008
    Location
    Groningen - Netherlands
    Posts
    1,114
    Answers
    83
    Vote Rating
    30
    tvanzoelen has a spectacular aura about tvanzoelen has a spectacular aura about tvanzoelen has a spectacular aura about

      0  

    Default


    And is the store loaded? Else there will be no change or select possible.

  8. #8
    Sencha User
    Join Date
    Aug 2012
    Posts
    15
    Vote Rating
    0
    messyOne is on a distinguished road

      0  

    Default


    Yes! The store is loaded. I have a lot of items in the list.

  9. #9
    Ext JS Premium Member tvanzoelen's Avatar
    Join Date
    Apr 2008
    Location
    Groningen - Netherlands
    Posts
    1,114
    Answers
    83
    Vote Rating
    30
    tvanzoelen has a spectacular aura about tvanzoelen has a spectacular aura about tvanzoelen has a spectacular aura about

      0  

    Default


    But the error is gone. What happens now? No event, no log?

  10. #10
    Sencha User
    Join Date
    Aug 2012
    Posts
    15
    Vote Rating
    0
    messyOne is on a distinguished road

      0  

    Default


    Oh, yes. The error is gone, but no log.

    Edit: The error came but only if I try to add the listener in the ExtJS script to the object.

Thread Participants: 2

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi