0

这是我的代码

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

所以我有组合框,其存储为 autoLoad:true,但是当我单击组合框按钮时,它会将请求重新发送到服务器。我不希望这样,我只想在有人在其中输入内容时才将请求发送到服务器。

4

1 回答 1

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 项目中选择。

于 2016-08-01T05:52:39.297 回答