Results 1 to 5 of 5

Thread: Combo getValue

  1. #1
    Sencha User
    Join Date
    Apr 2011
    Location
    Spain
    Posts
    77

    Default Combo getValue

    I have this combo in a form:
    Code:
    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:
    Code:
    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():
    Code:
      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:
    Code:
    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

  2. #2
    Sencha User sword-it's Avatar
    Join Date
    May 2012
    Location
    Istanbul
    Posts
    1,335
    Answers
    124

    Default

    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!!!!!
    sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.

  3. #3
    Sencha User
    Join Date
    Apr 2011
    Location
    Spain
    Posts
    77

    Default

    Quote Originally Posted by sword-it View Post
    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.

  4. #4
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,410
    Answers
    716

    Default

    I use '\n' because this text has been introduced first in a textarea form,
    Perhaps you should strip them out?

    Scott.

  5. #5
    Sencha User
    Join Date
    Apr 2011
    Location
    Spain
    Posts
    77

    Default

    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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •