Я использую ExtJS 4.1. Я пытаюсь дождаться загрузки всех хранилищ для comboboxes. Я слушаю событие beforerender окна.Extjs 4.1 Дождаться загрузки магазинов в окне для нескольких списков со списком
В этом случае, если счетчик combobox не определен, я получаю все выпадающие списки, сохраняю счет, загружаю магазины и регистрирую обратный вызов, который уменьшает счетчик combobox. Когда счетчик будет равен нулю, он вызовет метод show, и появится окно.
Если значение combobox определено, то если оно равно нулю, я возвращаю true, чтобы окно отображалось, в противном случае я возвращаю false.
Однако проблема заключается в том, что не все выпадающие списки отображают displayValue и вместо этого показывают значение valueField.
console.log('--- onWindowBeforeRender');
if (typeof this.comboboxCount != 'undefined') {
if (this.comboboxCount == 0) {
console.log('returning true:');
return true;
}
else {
console.log('returning false1:');
return false;
}
}
var x = component.query('combobox');
console.log('x.length:');
console.log(x.length);
this.comboboxCount = x.length;
for (var i = 0; i < x.length; i++) {
var y = x[i];
console.log('y:'+i);
console.log(y);
y.store.load({
scope: this,
callback: function(records, operation, success) {
this.comboboxCount--;
console.log('comboboxCount:' + this.comboboxCount);
if (!this.comboboxCount) {
console.log('all stores loaded.');
this.show();
}
}
});
}
console.log('returning false2');
return false;
Вот код для Наримера:
{
xtype: 'combobox',
anchor: '100%',
fieldLabel: 'Region',
name: 'region_id',
displayField: 'name',
store: 'RegionStore',
valueField: 'id'
},
{
xtype: 'combobox',
anchor: '100%',
fieldLabel: 'Country',
name: 'country_id',
displayField: 'name',
store: 'CountryStore',
valueField: 'id'
}
Вот магазины:
Ext.define('RR.store.CountryStore', {
extend: 'Ext.data.Store',
requires: [
'RR.model.CountryModel'
],
constructor: function(cfg) {
var me = this;
cfg = cfg || {};
me.callParent([Ext.apply({
model: 'RR.model.CountryModel',
storeId: 'CountryStore',
proxy: {
type: 'ajax',
api: {
create: '/country/create',
read: '/country/read',
update: '/country/update'
},
reader: {
type: 'json',
root: 'countrys'
}
}
}, cfg)]);
}
});
Ext.define('RR.store.RegionStore', {
extend: 'Ext.data.Store',
requires: [
'RR.model.RegionModel'
],
constructor: function(cfg) {
var me = this;
cfg = cfg || {};
me.callParent([Ext.apply({
model: 'RR.model.RegionModel',
storeId: 'RegionStore',
proxy: {
type: 'ajax',
api: {
create: '/region/create',
read: '/region/read',
update: '/region/update'
},
reader: {
type: 'json',
root: 'regions'
}
}
}, cfg)]);
}
});
Ну это звучит ваша проблема о комбо так что вы вы должны опубликовать некоторые код для них? – sra
Как и когда вы устанавливаете значение своих комбо? – rixo
Я не устанавливаю явно значения комбо, поле «имя» является id для значенияField. – jwc