PDA

View Full Version : Combo getValue



Fanny144
17 May 2012, 3:17 AM
I have this combo in a form:


cbEquipos = Ext.create('Ext.form.field.ComboBox',{ allowBlank: false,
deferEmptyText: false,
displayField: 'descripcion',
editable: false,
fieldLabel: this.flEquipo,
forceSelection: true,
lastQuery: '',
name: 'idEquipo',
queryMode: 'local',
store: storeEquipos,
valueField: 'idEquipo'
});

When I select a value like this:

idEquipo: 1, descripcion: "asdasdasdad"
the function getValue() returns a correct result, but if I select other value where the field descripccion has a text with line break, getValue() is incorrect because it returns the value of the field descripccion instead of the value of the valueField.
I've been reviewing the code and in the function getValue():

getValue: function() { // If the user has not changed the raw field value since a value was selected from the list,
// then return the structured value from the selection. If the raw field value is different
// than what would be displayed due to selection, return that raw value.
var me = this,
picker = me.picker,
rawValue = me.getRawValue(), //current value of text field
value = me.value; //stored value from last selection or setValue() call


if (me.getDisplayValue() !== rawValue) {
value = rawValue;
me.value = me.displayTplData = me.valueModels = null;
if (picker) {
me.ignoreSelection++;
picker.getSelectionModel().deselectAll();
me.ignoreSelection--;
}
}


return value;
},

In this line:
if (me.getDisplayValue() !== rawValue) { the displayValue is different of the rawValue then the value of the combo will has the same value of the rawValue.


Have someone help for this bug??

Thanks

sword-it
17 May 2012, 4:18 AM
Hi Fanny144,
I am still wondering why you are using '\n' while you can use a simple space in your description field value.

Remove '\n' and try again with 'SPACE'...it is working on my side...will also works at yours!!!!!

Fanny144
17 May 2012, 4:26 AM
Hi Fanny144,
I am still wondering why you are using '\n' while you can use a simple space in your description field value.

Remove '\n' and try again with 'SPACE'...it is working on my side...will also works at yours!!!!!

I use '\n' because this text has been introduced first in a textarea form, and then this values are the store of the combo.

scottmartin
17 May 2012, 7:59 AM
I use '\n' because this text has been introduced first in a textarea form,

Perhaps you should strip them out?

Scott.

Fanny144
21 May 2012, 3:37 AM
And where can I put the trim of the displayField showed on the combo??
Because if I change it in the innerTpl, I'm only changing the displayField not the submitValue.
If I get the value of the combo when I will submit the form, this value is wrong already.