1. #1
    Sencha User
    Join Date
    Oct 2009
    Posts
    15
    Vote Rating
    0
    seltzlab is on a distinguished road

      0  

    Default combobox beforeselect

    combobox beforeselect


    Hi all,
    it seems that the beforeselect event of a combobox fires before the select event but the select event does not wait the beforeselect handler has returned.. it simply fire immediately after.
    There's a way to fire the select event only after the beforeselect handler has finished?

    Thanks a lot,
    Antonio

  2. #2
    Sencha User
    Join Date
    Apr 2008
    Posts
    330
    Vote Rating
    0
    Jack_S is on a distinguished road

      0  

    Default


    Hello Antonio,

    I've been having the same problem with comboboxes, and have not yet found a solution. It seem that the SQLiteStore ignores this, as far as I can tell, but it shouldn't as its just an extension of Ext.data.Store.

    Anybody can comment on this?

    Jack

  3. #3
    Sencha User makana's Avatar
    Join Date
    Apr 2008
    Location
    Dresden, Germany
    Posts
    527
    Vote Rating
    19
    makana has a spectacular aura about makana has a spectacular aura about

      0  

    Default


    Hi!
    It's hard to understand.
    Can you give some example code, please?
    Programming today is a race between software engineers striving to build bigger and better Ń–diot-proof programs, and the universe striving to produce bigger and better idiots. So far, the universe is winning. (Rick Cook)

    Enhanced ExtJS adapter for Adobe AIR

  4. #4
    Sencha User
    Join Date
    Aug 2011
    Posts
    3
    Vote Rating
    0
    morphe83 is on a distinguished road

      0  

    Default here is the solution to add the event 'beforeselect'

    here is the solution to add the event 'beforeselect'


    Code:
    Ext.override(Ext.form.ComboBox,
        {
            onListSelectionChange: function(list, selectedRecords) {
                var me = this;
                // Only react to selection if it is not called from setValue, and if our list is
                // expanded (ignores changes to the selection model triggered elsewhere)
                if (!me.ignoreSelection && me.isExpanded) {
                    var allowSelect = true;
                    var lastSelectedRecord = me.picker.getSelectionModel().lastSelected;
    
    
                    if (lastSelectedRecord != undefined)
                        allowSelect = me.fireEvent('beforeselect', me, lastSelectedRecord) !== false;
                        
                    if(allowSelect)
                    {
                        if (!me.multiSelect) {
                            Ext.defer(me.collapse, 1, me);
                        }
                        me.setValue(selectedRecords, false);
                        if (selectedRecords.length > 0) {
                            me.fireEvent('select', me, selectedRecords);
                        }
                        me.inputEl.focus();
    
    
                    } else {
                        me.picker.getSelectionModel().deselect(lastSelectedRecord);
                    }
                }
            }
     });

Thread Participants: 3