Javascript 键入时组合框值正在消失

Javascript 键入时组合框值正在消失,javascript,extjs,combobox,extjs5,Javascript,Extjs,Combobox,Extjs5,使用extjs 5.1.3版本。我有一个排字框,格式如下: 组合框存储: Ext.define('MyApp.view.myobj.field.CustomObject', { extend:'Ext.form.field.ComboBox', xtype: 'cstmObject', requires: [ 'MyApp.model.myobj.CustomObject' ], fieldLabel: 'Custom Object Nam

使用extjs 5.1.3版本。我有一个排字框,格式如下:

组合框存储:

Ext.define('MyApp.view.myobj.field.CustomObject', {
    extend:'Ext.form.field.ComboBox',
    xtype: 'cstmObject',
    requires: [
        'MyApp.model.myobj.CustomObject'
    ],
    fieldLabel: 'Custom Object Name',
    displayField: 'name',
    valueField: 'name',
    queryMode: 'remote',
    selectOnFocus: false,
    typeAhead: true,
    hideTrigger: true,
    minChars: 1,
    queryCaching : false,
    store:{
        model: 'MyApp.model.myobj.CustomObject'
    }
}
以下是表单中的代码段:

{
    xtype: 'cstmObject',
    fieldLabel: 'Custom Object Name',
    allowBlank: false,
    maxLength: 5,
    enforceMaxLength: true,
    bind: '{customObject.row}'
}
在combobox中键入值时,有时显示输入的下拉列表值,有时不显示。当我观察网络面板时,存储正在从服务器正确加载

当存储正确地从服务器加载时,如果不显示下拉列表值,客户端可能会出现什么问题

更新:我找到了问题的模式,即如果在下拉列表中找到与键入值完全匹配的记录,则只有下拉值消失。(例如,如果我键入字母表A,并且如果有一条记录的值A,则下拉列表值将消失。如果我键入A,则下拉列表不会消失,因为没有小写的A记录)


我需要提供什么样的配置来修复此问题?

我有如下Extjs组合:

{
xtype       :'combo',
emptyText   :'Pilih Client ...',
id          :'f_client',
store       : 'store_client',
displayField:'longname',
typeAhead   : true,
valueField  :'nickname',
width       : 350
}
我尝试用小写或大写来搜索数据,所以我认为您必须在服务器端再次检查。因为像oracle这样的查询是区分大小写的

column1 like '%a%'


不同。

Ext.form.field.ComboBox
的属性默认为
false
。这意味着问题可能在您的控制范围内,但前提是此属性设置为
true
。如果此属性为
false
,您可以在控制台(或使用Chrome的Sencha扩展)中进行检查


还可以在控制台的“网络”选项卡中查看发送到服务器的内容。如果组合框发送大写字母,但服务器返回小写字母,则问题出在服务器端。

这似乎是Ext5.1中的一个错误

仅当组件绑定到模型时才会发生这种情况

这里是复制这个问题。键入A您将看到结果,当您键入A1(存储中存在)时,结果将被隐藏

已登录Ext5论坛

更新

我想出了一个解决办法

Ext.define('MyApp.overrides.form.field.ComboBox', {
    override: 'Ext.form.field.ComboBox',

    /**
     * Fix for EXTJS-19274
     */
    setValue: function(value) {
        var me = this;

        // This is the value used to forceSelection in assertValue if an invalid value is left
        // in the field atcompleteEdit. Must be cleared so that the next usage of the field
        // is not affected.
        me.lastSelectedRecords = null;

        // Value needs matching and record(s) need selecting.
        if (value != null) {
            // Only go through text/record matching if there's a change.
            if (value !== me.getRawValue()) {
                me.doSetValue(value);
            }
        }
        // Clearing is a special, simpler case.
        else {
            me.suspendEvent('select');
            me.valueCollection.beginUpdate();
            me.pickerSelectionModel.deselectAll();
            me.valueCollection.endUpdate();
            me.resumeEvent('select');
        }
        return me;
    }
});
小提琴以你想要的方式工作,除了灯光的选择来自商店。我注意到的是,我必须将组合框直接绑定到一个商店,这样它才能在键入A1后工作而不隐藏


对于其他查看本期所列其他小提琴的人来说,如果你非常缓慢地键入A1,你将看不到其行为。如果您键入的速度与您通常在写文章时的速度相同,或者当您看到显示的自动完成消失时的速度相同,那么它应该可以工作(我在一个应用程序中尝试了您的代码)。也许你可以试着用小提琴来重现这个问题,或者发布服务器对工作和中断案例的响应示例。在我看来,这个问题似乎与服务器有关。看看下面乔纳森·卡特赖特的小提琴。我在那把小提琴里藏着完全相同的东西,直到我为组合框使用了sata源存储。如果我的提琴上还有它,请告诉我。当我们将它绑定到模型时,问题正在发生。没有约束力就没有问题。看看你的小提琴,它没有绑定到模型上,所以它工作得很好。
Ext.define('MyApp.overrides.form.field.ComboBox', {
    override: 'Ext.form.field.ComboBox',

    /**
     * Fix for EXTJS-19274
     */
    setValue: function(value) {
        var me = this;

        // This is the value used to forceSelection in assertValue if an invalid value is left
        // in the field atcompleteEdit. Must be cleared so that the next usage of the field
        // is not affected.
        me.lastSelectedRecords = null;

        // Value needs matching and record(s) need selecting.
        if (value != null) {
            // Only go through text/record matching if there's a change.
            if (value !== me.getRawValue()) {
                me.doSetValue(value);
            }
        }
        // Clearing is a special, simpler case.
        else {
            me.suspendEvent('select');
            me.valueCollection.beginUpdate();
            me.pickerSelectionModel.deselectAll();
            me.valueCollection.endUpdate();
            me.resumeEvent('select');
        }
        return me;
    }
});