gpt4 book ai didi

javascript - ExtJS ComboBox(配置了 queryMode remote 和 forceSelection true)自动清除输入字段

转载 作者:行者123 更新时间:2023-11-30 00:22:11 24 4
gpt4 key购买 nike

组件Ext.form.field.ComboBox配置了 queryMode“remote”和 forceSelection true 会在搜索商店后自动清除其输入字段。

{
xtype: 'combobox',

fieldLabel: 'State',

forceSelection: true,
queryMode: 'remote',
displayField: 'name',
valueField: 'id',
typeAhead: true,
minChars: 0,

store: {
model: 'ComboTest.State',
pageSize: 100,

proxy: {
type: 'ajax',
url: 'states.js',
reader: {
type: 'json',
}
}
},

allowBlank: false

}

你可以试试这个 fiddle :https://fiddle.sencha.com/#fiddle/uaq

例如插入“w”,组合框选择“华盛顿”,然后继续插入“y”(例如您想要“怀俄明”),此时一切都被清除。

我是做错了什么还是错误?

最佳答案

这是 extjs 5 中的一个常见错误,我猜它存在于 extjs 6 中。

您可以覆盖组合框行为:

Ext.define('overrides.form.ComboBox', {
override: 'Ext.form.ComboBox',
onLoad: function (store, records, success) {
var me = this,
needsValueUpdating = !me.valueCollection.byValue.get(me.value);
if (success && needsValueUpdating && !(store.lastOptions && 'rawQuery' in store.lastOptions)) {
me.setValueOnData();
}
},
beforeBlur: function () {
var me = this;
if (me.getRawValue().length === 0 || (me.getValue() == null && this.forceSelection)) {
me.reset();
me.lastSelection = [];
}
me.callParent(arguments);
}
});

关于javascript - ExtJS ComboBox(配置了 queryMode remote 和 forceSelection true)自动清除输入字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32740736/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com