1. #1
    Ext JS Premium Member cmeans's Avatar
    Join Date
    Jun 2010
    Location
    Chicago, IL USA
    Posts
    112
    Answers
    3
    Vote Rating
    7
    cmeans is on a distinguished road

      0  

    Question Unanswered: How to stop ComboBox trigger on store.add(record)

    Unanswered: How to stop ComboBox trigger on store.add(record)


    ExtJS v4.1.1a.

    I have a ComboBox with a local store that's working fine, except that when I programmatically add a record to it's store, the "trigger" appears to be firing (causing the drop down list to app and show the entry I just added).

    Is there a config setting to suppress this behaviour or am I possibly doing something else wrong?

    Thanks.

    -Chris

  2. #2
    Sencha - Support Team
    Join Date
    Mar 2012
    Location
    Lawrence, KS
    Posts
    282
    Answers
    41
    Vote Rating
    35
    greg.barry has a spectacular aura about greg.barry has a spectacular aura about

      0  

    Default No Trigger

    No Trigger


    Chris,

    I made a small test case and I can't seem to recreate what you have described. The record is successfully added to the store and the combobox remains the same. In other words, it does not appear to trigger.

    Code:
    Ext.onReady(function () {
        var states = Ext.create('Ext.data.Store', {
            fields: ['abbr', 'name'],
            data : [
                {"abbr":"PF", "name":"Pink Floyd"}
            ]
        });
    
    
        Ext.create('Ext.form.ComboBox', {
            fieldLabel: 'Choose State',
            store: states,
            queryMode: 'local',
            displayField: 'name',
            valueField: 'abbr',
            renderTo: Ext.getBody()
        });
    
    
        Ext.create('Ext.Button', {
            text: 'Press Me',
            renderTo: Ext.getBody(),
            listeners: {
                click: function(){
                    states.add({"abbr":"LZ", "name":"Led Zeppelin"});
                }
            }
        });
    });
    Thanks!
    Greg

  3. #3
    Ext JS Premium Member cmeans's Avatar
    Join Date
    Jun 2010
    Location
    Chicago, IL USA
    Posts
    112
    Answers
    3
    Vote Rating
    7
    cmeans is on a distinguished road

      0  

    Default


    Hi Greg,

    It appears you are correct.

    What I wasn't seeing is that the act of typing in the combo box was triggering it to "open up" the drop down list...it's just not so visible when there's nothing there. However, because the store.add call adds an entry, it's then displayed in the already open list.

    I do want the list displayed if there's a matching entry, but I'd like to suppress it if I have to add one.

    Any suggestions on the best approach?

    Thanks for your help.

    -Chris

Thread Participants: 1