作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
组件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/
我很沮丧,因为每当我使用它来支持组合字段时,我的商店都会不断被过滤。有什么办法可以禁用它吗? 场景 我有一个 data 的商店场上;实例化存储时加载的对象数组。我使用这家商店在我的应用程序的不同区域驱
我使用的是 Ext 4.1.1 我有一个为 queryMode:"local"启用 typeAhead 的组合框。只要您只查询 displayField 的前缀,它就可以正常工作。但是,当您在该显示字
组件Ext.form.field.ComboBox配置了 queryMode“remote”和 forceSelection true 会在搜索商店后自动清除其输入字段。 { xtype: '
我是一名优秀的程序员,十分优秀!