extjs combobox triger仅在文本类型之后但不在点击之后

时间:2016-07-29 10:35:36

标签: javascript extjs combobox extjs6 extjs6-modern

这是我的代码

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

所以我有了combobox whos store是autoLoad:true, 但是当我点击组合框按钮时,它会将请求重新发送到服务器。我不想要那个,我只想在有人输入内容时将请求发送到服务器。

1 个答案:

答案 0 :(得分: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.
                         }                         
                    }
                   }
                }

我在你的组合框中添加了两个配置属性:

triggerAction : 'all',
queryMode     : 'local'

现在,当你在你的组合框中写一些东西然后改变事件被激活。

选择任何下拉项时,

change事件也会被触发。因此,您可以检查更改的值是新的书面值还是已从dorpdown项目中选择。