我有具有连接到远程存储多个组合框字段的表单:使用Ext.form.Basic.loadRecord将数据加载到组合框的字段远程商店
Ext.define('app.ux.form.MyCombo', {
extend: 'Ext.form.field.ComboBox',
alias: 'widget.mycombo',
store: this.store,
displayField: 'displayField',
valueField: 'valueField',
forceSelection: true,
autoSelect: true,
initComponent: function() {
this.addEvents('selectitem');
this.enableBubble('selectitem');
this.callParent(arguments);
this.listeners = {
change: function(field, value) {
this.fireEvent('selectitem', field, value);
}
}
}
})
fieldLabel: 'DisabilityType',
name: 'f_disability_type',
xtype: 'combo',
valueField: 'valueField',
displayField: 'displayField',
forceSelection: true,
autoSelect: true,
store: 'DisabilityTypes'
DisabilityTypes是一个基本的分机将autoLoad设置为false并将autoSync设置为true的.data.store。当您点击与商店关联的下拉菜单时,商店会加载并显示值列表。
当我在包含此下拉列表的BasicForm对象上调用loadRecord并将其传递给模型时,它会填充使用本地存储的组合框,但不会加载使用远程存储的组合框。这是因为组合框存储未加载(autoLoad:false),或者在窗体加载后加载组合框(autoLoad:true)。
我知道,这是在内线3.3.x一个问题,有提出解决它的一个插件:
/**
* When combo box is used on a form with dynamic store (remote mode)
* then sometimes the combobox store would load after the form data.
* And in that case the setValue method of combobox will not
* set the combobox value properly. This override makes sure that the
* combobox store is completely loaded before calling the setValue method.
*/
Ext.override(Ext.form.ComboBox, {
setValue : function(v){
var text = v;
if(this.valueField){
if(!Ext.isDefined(this.store.totalLength)){
this.store.on('load', this.setValue.createDelegate(this, arguments), null, {single: true});
if(this.store.lastOptions === null){
var params;
if(this.valueParam){
params = {};
params[this.valueParam] = v;
}else{
var q = this.allQuery;
this.lastQuery = q;
this.store.setBaseParam(this.queryParam, q);
params = this.getParams(q);
}
this.store.load({params: params});
}
return;
}
var r = this.findRecord(this.valueField, v);
if(r){
text = r.data[this.displayField];
}else if(this.valueNotFoundText !== undefined){
text = this.valueNotFoundText;
}
}
this.lastSelectionText = text;
if(this.hiddenField){
this.hiddenField.value = v;
}
Ext.form.ComboBox.superclass.setValue.call(this, text);
this.value = v;
}
});
有这个问题被固定在内线4?或者我需要找到另一个与Ext 4兼容的插件?
它工作正常,至少在4.0.7中“低于2”的比较,我不,你知道使用至极的版本,但如果我叫的setValue()的组合如果商店尚未加载,并且商店具有autoLoad:true,则会先加载商店,然后再设置该值。 – VoidMain 2011-11-18 18:57:55