Events ExtJS 6:TreePicker不触发更改事件
请看这里的小提琴: 事件部分的docs()列表Events ExtJS 6:TreePicker不触发更改事件,events,extjs,extjs6,extjs6-classic,treepanel,Events,Extjs,Extjs6,Extjs6 Classic,Treepanel,请看这里的小提琴: 事件部分的docs()列表'change',但当我设置值或重置字段时,此事件不会触发。'select'事件按预期触发,但仅当用户选择字段时才会触发 编辑: 根据下面Snehal的建议,我能够使用以下覆盖来完成这项工作。不确定是否有更简单的方法,但这是我能做到的最好的方法: Ext.define('MyApp.overrides.TreePicker', { override: 'Ext.ux.TreePicker', setValue: function (
'change'
,但当我设置值或重置字段时,此事件不会触发。'select'
事件按预期触发,但仅当用户选择字段时才会触发
编辑:
根据下面Snehal的建议,我能够使用以下覆盖来完成这项工作。不确定是否有更简单的方法,但这是我能做到的最好的方法:
Ext.define('MyApp.overrides.TreePicker', {
override: 'Ext.ux.TreePicker',
setValue: function (value) {
var me = this,
record;
me.value = value;
if (me.store.loading) {
// Called while the Store is loading. Ensure it is processed by the onLoad method.
return me;
}
// try to find a record in the store that matches the value
record = value ? me.store.getNodeById(value) : me.store.getRoot();
if (value === undefined) {
record = me.store.getRoot();
me.value = record.getId();
} else {
record = me.store.getNodeById(value);
}
// zeke - this is the only line I added to the original source
// without this the 'change' event is not fired
me.callSuper([value]);
// set the raw value to the record's display field if a record was found
me.setRawValue(record ? record.get(me.displayField) : '');
return me;
}
});
因为
setValue
函数不调用this.callParent()
。您可以在setValue
函数中执行类似操作
setValue: function(value) {
var me = this,
record;
if (me.store.loading) {
// Called while the Store is loading. Ensure it is processed by the onLoad method.
return me;
}
// try to find a record in the store that matches the value
record = value ? me.store.getById(value) : me.store.getRoot();
me.callParent([record.get('valueField')]);
return me;
},