Jez D
Jez D

Reputation: 1487

Pass selectfield value to listener function

I have a listener in a view, which detects a change in a selectfield.

This is the selectfield:

{
    xtype : 'selectfield',
    store : companiesStore2,
    name : 'companies',
    id : 'companiesSelect',
    itemId: 'companySelect',
    valueField : 'companyname',
    displayField : 'companyname',
},

And the listener:

listeners: [{
    delegate: '#companySelect',
    event: 'change',
    fn: 'onGetStatsCommand'
}],

onGetStatsCommand: function () {
    this.fireEvent('onGetStatsCommand');
},

The function that fires is in the controller and looks like this:

onGetStatsCommand: function () {
    alert('HERE WE GO')
},

This all works fine, but, what I need to do is pass the value of the selected item to the onGetStatsCommand function.

How do I do this?

Upvotes: 0

Views: 104

Answers (1)

Jacobian
Jacobian

Reputation: 10872

I'm not sure about the syntax, but if my intuition serves me right, it should be :

this.fireEvent('onGetStatsCommand',Ext.getCmp('companiesSelect').getValue());

onGetStatsCommand: function (val) {
   alert(val)
}

Upvotes: 2

Related Questions