PDA

View Full Version : store.filter or store.reload .. wheres the problem? (chained link combo boxes)



dancaescu
5 Jan 2012, 8:52 AM
Hi,

I have the following code for the first combo:



field: {
xtype: 'combobox',
id: 'brand',
store: brands,
displayField: 'name',
valueField: 'id',
queryMode: 'local',
typeAhead: true,
forceSelection: true,
triggerAction: 'all',
viewConfig: {validateOnBlur: false},
selectOnFocus:true,
emptyText: 'Select brand',
listeners: {
select: { fn:function(combo, value) {
console.log('changing the next combo');
var modelDest = Ext.getCmp('model');
console.log(modelDest.getValue());
console.log(combo.getValue());
modelDest.setDisabled(true);
modelDest.setValue('');
modelDest.store.removeAll();
modelDest.store.filter('brand_id', combo.getValue());
modelDest.store.reload({
params: { brand_id: combo.getValue() }
});
modelDest.setDisabled(false);
}
},
scope: this
}


The model used by second combo looks like this:



Ext.define('Model', {
extend: 'Ext.data.Model',
fields: [{
name: 'id',
type: 'int',
useNull: true
}, 'name','brand_id','lines']
});


and the store for this , below:



var models = Ext.create('Ext.data.Store',{
autoLoad: true,
autoSync: false,
id: 1,
extraParams: {
brand_id: ''
},
model: 'Model',
restful: true,
proxy: {
type: 'rest',
url: 'models/',
reader: {
type: 'json',
root: 'models'
},



Problems below:

1. if I use modelDest.store.filter('brand_id', combo.getValue()); in the listener, i get no results in the second combo
2. if I use modelDest.store.reload({ in the listener, i get the following error message:
"modelDest.store.reload is not a function"
3. if I use model.Dest.store.load({ in the listener, the second combo box gets populated correctly, but when choosing a value, that value is set for all columns in the grid for the "model" combo box

What am I doing wrong?

Thanks,
Dan

mitchellsimoens
5 Jan 2012, 12:35 PM
Please post into the appropriate forum. I have moved this to the Ext JS 4 Q&A forum for you.

dancaescu
6 Jan 2012, 5:22 AM
Attached -- full version.
I did some more changes, tweaking around with this and that, now it randomly clears out the Model column, and also randomly loading it back.

Some help please?