1. #1
    Sencha User
    Join Date
    Jun 2011
    Posts
    131
    Answers
    1
    Vote Rating
    1
    shaoen01 is on a distinguished road

      0  

    Default Unanswered: Using ComboBox to get Old Value?

    Unanswered: Using ComboBox to get Old Value?


    Hi all,

    I am currently using a combo box or dropdown menu on my grid with roweditor plugin. I would like to know the old value before it was selected. I am using the change listener to do that. However, there are a few ways to select the value. Either you use a mouse click to select (in this case change will be fired) or you can type in and there's an autocomplete.

    So in the auto-complete mode, say the actual value is "abc123" and i am typing "ab" it will show a potential match. So i normally just do a tab and the full value gets populated. So in this case, i am unable to get the old value. Could it be that change event is not fired? Any advise on how to handle non mouse-click selection?

    Code:
    field: {
                    xtype: 'combobox',
                    id: "namecombo",
                    typeAhead: true,
                    triggerAction: 'all',
                    selectOnTab: true,
                    store: userstorecombo,
                    displayField: 'fullname',
                    //valueField: 'productid',
                    lazyRender: true,
                    allowBlank:false,
                    listClass: 'x-combo-list-small',
                    msgTarget: 'side',
                    queryMode: 'local',
                     listeners: {
                        scope: this,
                        select: function(field, value, options) 
                        {
                            selected_combo_display=field.getRawValue();
                                
                        },
                        change: function (field, newValue, oldValue, options) {
                          selected_combo_display=newValue;
                          selected_combo_display_old=oldValue
                            
                        }
                      }//end listener
                    
                  }

  2. #2
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,592
    Answers
    541
    Vote Rating
    324
    skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future

      0  

    Default


    Why do you need the old value? There are loads of ways to get hold of the old value but it's difficult to say what's best without knowing the use case. Until the edit completes the old value will be accessible through the record. The events beforeedit and validateedit both provide an opportunity to grab it.

    The change event should fire no matter how the value was changed, though it may only fire when the field blurs. Add in some console logging to confirm. You need to be careful though, if the change event fires multiple times then your 'old value' will not be the original value, it will be the value from the previous change event.

  3. #3
    Sencha User
    Join Date
    Jun 2011
    Posts
    131
    Answers
    1
    Vote Rating
    1
    shaoen01 is on a distinguished road

      0  

    Default


    Thanks, i think i will have to find another way to do it.

Thread Participants: 1