Rose18
Rose18

Reputation: 3162

ExtJs 3.4 : Concatenate selected value of a combo into a label text

I have an Ext combo box in a form panel as following.

new Ext.form.ComboBox({
    store : routeStore,
    displayField : 'rName',
    valueField : 'rName',
    fieldLabel : 'Select Fixed Route',
    id : 'routeCombo',
    typeAhead : true,
        forceSelection : true,
    mode : 'local',
    triggerAction : 'all',
    selectOnFocus : true,
    editable : true,
    hidden : false,
    disabled : true,
    minChars : 1,
        hideLabel : true,
    width : 210,
    emptyText : 'Select Fixed Route'

})

An also I have a label like this.

{
        xtype : 'label',
        id : 'idTourCode',
        text : 'SystemDate',
        forId : 'myFieldId',
        style : 'marginleft:10px',
        //autoWidth : true,
        flex : 1
    }

Now I need to concatenate the selected value of the combo box to my label text. This label already has a text. What I want is, the selected value of the combo should be concatenate to this label text. All of these things should be happen on a button click.

I've tried to find a solution but no luck. Therefore, please be kind enough to help me to clarify my problem.

Thanx a lot

Upvotes: 0

Views: 569

Answers (1)

BillyTom
BillyTom

Reputation: 2719

This is a crude fix.

Add this to your combobox:

listeners: {
    change: function(box, newValue)
    {
        Ext.ComponentQuery.query("#myLabel")[0].setText(newValue)
    }

Add this to your label:

itemId: 'myLabel'

You should polish this a bit and find a better to access you combobox than Ext.ComponentQuery, because it is really slow.

Upvotes: 1

Related Questions