i_love_gillou
9 Jan 2012, 12:23 PM
Hi all,
Extjs 4.0.7
Here is my problem: I have 2 linked combos with 2 stores bound to each, and my goal is to load the content of the second one on the select event of the first one. To do so i have configured two stores and two models:
Models:
Ext.define('GIV.model.Fonction', {
extend: 'Ext.data.Model',
fields: ['id', 'libelle_fonction'],
proxy: {
type: 'ajax',
url: 'fonction',
reader: {
type: 'json',
root: 'results',
successProperty: 'success'
}
});
Ext.define('GIV.model.Type', {
extend: 'Ext.data.Model',
fields: ['id', 'libelle_type'],
proxy: {
type: 'ajax',
url: 'type/fonction/',
reader: {
type: 'json',
root: 'results',
successProperty: 'success'
}
}
});
Stores
Ext.define('GIV.store.Fonctions', {
extend: 'Ext.data.Store',
requires: 'GIV.model.Fonction',
model: 'GIV.model.Fonction',
autoLoad: true
});
Ext.define('GIV.store.Types', {
extend: 'Ext.data.Store',
requires: 'GIV.model.Type',
model: 'GIV.model.Type',
autoLoad: false
});
And then in the controller:
...
init: function(){
this.control({
'#cbFonction': {
select: this.onSelectCbFonction
}
});
},
onSelectCbFonction: function(combo, records, elOpts){
var cbType = Ext.getCmp('cbType');
cbType.clearValue();
cbType.getStore().load({ url: 'type/fonction/' + combo.getValue() });
cbType.setLoading(false);
}
...
combos:
/* FONCTION */
var fonctionCombo = Ext.create('Ext.form.field.ComboBox', {
id: 'cbFonction',
fieldLabel: 'Fonction',
store: 'Fonctions',
queryMode: 'local',
displayField: 'libelle_fonction',
valueField: 'id',
flex: 1,
labelAlign: 'top',
editable: false
});
var typeCombo = Ext.create('Ext.form.field.ComboBox', {
id: 'cbType',
fieldLabel: 'Type',
store: 'Types',
queryMode: 'local',
displayField: 'libelle_type',
valueField: 'id',
flex: 1,
labelAlign: 'top',
editable: false
});
When an item in the combo 'cbFonction' is selected, the content of the second combo is loaded but the loading spinner never disappear (even with the setLoading is set to false)
What am i doing wrong?
Thanks!
Extjs 4.0.7
Here is my problem: I have 2 linked combos with 2 stores bound to each, and my goal is to load the content of the second one on the select event of the first one. To do so i have configured two stores and two models:
Models:
Ext.define('GIV.model.Fonction', {
extend: 'Ext.data.Model',
fields: ['id', 'libelle_fonction'],
proxy: {
type: 'ajax',
url: 'fonction',
reader: {
type: 'json',
root: 'results',
successProperty: 'success'
}
});
Ext.define('GIV.model.Type', {
extend: 'Ext.data.Model',
fields: ['id', 'libelle_type'],
proxy: {
type: 'ajax',
url: 'type/fonction/',
reader: {
type: 'json',
root: 'results',
successProperty: 'success'
}
}
});
Stores
Ext.define('GIV.store.Fonctions', {
extend: 'Ext.data.Store',
requires: 'GIV.model.Fonction',
model: 'GIV.model.Fonction',
autoLoad: true
});
Ext.define('GIV.store.Types', {
extend: 'Ext.data.Store',
requires: 'GIV.model.Type',
model: 'GIV.model.Type',
autoLoad: false
});
And then in the controller:
...
init: function(){
this.control({
'#cbFonction': {
select: this.onSelectCbFonction
}
});
},
onSelectCbFonction: function(combo, records, elOpts){
var cbType = Ext.getCmp('cbType');
cbType.clearValue();
cbType.getStore().load({ url: 'type/fonction/' + combo.getValue() });
cbType.setLoading(false);
}
...
combos:
/* FONCTION */
var fonctionCombo = Ext.create('Ext.form.field.ComboBox', {
id: 'cbFonction',
fieldLabel: 'Fonction',
store: 'Fonctions',
queryMode: 'local',
displayField: 'libelle_fonction',
valueField: 'id',
flex: 1,
labelAlign: 'top',
editable: false
});
var typeCombo = Ext.create('Ext.form.field.ComboBox', {
id: 'cbType',
fieldLabel: 'Type',
store: 'Types',
queryMode: 'local',
displayField: 'libelle_type',
valueField: 'id',
flex: 1,
labelAlign: 'top',
editable: false
});
When an item in the combo 'cbFonction' is selected, the content of the second combo is loaded but the loading spinner never disappear (even with the setLoading is set to false)
What am i doing wrong?
Thanks!