【问题标题】:extjs combobox triger only after text type but not on clickextjs 组合框仅在文本类型后触发,而不是在单击时触发
【发布时间】:2016-07-29 10:35:36
【问题描述】:

这是我的代码

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

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

【问题讨论】:

    标签: javascript extjs combobox extjs6 extjs6-modern


    【解决方案1】:
                      {
                        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 项中选择。

    【讨论】:

      猜你喜欢
      • 2017-10-18
      • 2019-09-25
      • 2011-11-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多