Cómo obtener el valor seleccionado en el campo de opción táctil Sencha

I have an select field, on screen. I want to get the selected value, on value change. so i have used the listener to the field. But it is printing only the value, which is nothign but the code for the product. How could i get the product name.

productCodes are : [{"state1", "state2", "state3"}]

productNames are : [{"Alabama", "Alaska", "Colordo"}]

var ProductList = new Ext.form.Select({
    layout: 'form',
    label: 'Product',
    id: 'productList',
    name: 'product',
    widht: '100%',
    labelWidth: '40%',
    autoLoad: true,
    autoDestroy: true,
    store: 'productStore',
    displayField: 'productName',
    valueField: 'productCode',
    listeners: {
        change: function (field, value) {
            console.log("product " + field + ' ' + value);
        }
    }
});

preguntado el 08 de noviembre de 11 a las 10:11

2 Respuestas

Hey Guys i made it working using the below code. Anyways thanks.

var temp =  field.store.findRecord('productCode', field.getValue());                          
console.dir(temp.data.productName);

respondido 08 nov., 11:15

can you show me where did you put this code. I am getting error upon error. - surhidamatya

thanks i got it solved it from stackoverflow.com/questions/7552571/… - surhidamatya

In combos use getRawValue() to get the text value displayed, its the value of the TextField input, so it would be ok, cleaner and easier for you to use field.getRawValue().

Espero que ayude.

respondido 08 nov., 11:17

but it is throwing Uncaught TypeError: Object [object Object] has no method 'getRawValue' - Nilanchala Panigrahy

Thats, probably, because you not using the correct object, every field (Ext.form.field descendant) has getRawValue() method, are you completelly sure that you tried this in a field Component and not and element? - Vacío principal

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.