0

here is my code

                     {
                        xtype: 'combobox',
                        minChars: 3,
                        anchor: '100%',
                        fieldLabel: 'Type',
                        name: 'typeName',
                        typeAhead: true,
                        mode: 'remote',  
                        emptyText: 'Select Type',
                        valueField: 'id',
                        bind: {
                            store: '{type}'
                        }
                    },

so I have combobox whos store is autoLoad:true, but when i click on the combobox button, it resend the request to server. i dont want that , i want to send the request to server only when someone type something in it.

Waqar Haider
  • 929
  • 10
  • 33

1 Answers1

0
                  {
                    xtype: 'combobox',
                    minChars: 3,
                    anchor: '100%',
                    fieldLabel: 'Type',
                    name: 'typeName',
                    typeAhead: true,
                    mode: 'remote',  
                    emptyText: 'Select Type',
                    valueField: 'id',
                    bind: {
                        store: '{type}'
                    },
                    triggerAction : 'all',
                    queryMode     : 'local',
                    listeners: {
                      change: function (field, newValue, oldValue) {
                        var store = field.getStore(),
                            rec =store.findRecord('id',newValue);
                        if(Ext.isEmpty(rec)){
                            // You can write the code to send the request to server.
                         }                         
                    }
                   }
                }

I have added two config property in you combobox:

triggerAction : 'all',
queryMode     : 'local'

Now when you will write something in your combobox then change event fired.

change event also fired when you select any dropdown item. So you can check it that changed value is new written value or already selected from dorpdown items.

jeanj
  • 2,106
  • 13
  • 22