PDA

View Full Version : Linked ComBoxes (lisstener filterBy problem)



tmchedlishvili
1 Jul 2013, 8:29 AM
hello friends please help me and give me some advice
i have two combobox
codes :

Ext.define('Exam.widget.EvaluationCombo', { extend: 'Ext.form.field.ComboBox',
requires: ['Ext.data.Store'],
alias: 'widget.evaluationcombo',


name: 'evaluationId',
displayField: 'evaluation',
valueField: 'id',
fieldLabel: '????????',

store: Ext.create('Ext.data.Store', {
fields: ['id', 'evaluation'],
data: [{
id: 1,
evaluation: "??????????"
}, {
id: 2,
evaluation: "??????????"
}]
})
});



and the second

Ext.define('Exam.widget.TemplatesCombo', { extend: 'Ext.form.field.ComboBox',
requires: ['Exam.store.Template'],
alias: 'widget.templatescombo',


name: 'templateId',
displayField: 'title',
valueField: 'id',
fieldLabel: '????????',

constructor: function (config) {
var me = this;

me.store = Ext.create('Exam.store.Template', {

proxy: {
type: 'dwr',
dwrFn: AdminMethods.getTemplates,
getDwrArgs: function() {
return null;
},
reader: {
type: 'json',
root: 'data'
}

}

});


me.callParent([config]);
}

});




this store has (Exam.store.Template) evaluationId and my goal is that EvaluationCombo's id will be 1/2 show corresponding data in the second combo which's evaluationId will be 1/2 ,
please help me if you can

slemmon
3 Jul 2013, 11:08 AM
On your first combobox you can add a select listener to load the second combo's store using the value from the first combobox.



{
listeners: {
select: function (combo, records) {
var record = records[0];
combo2.getStore().load({
params: {
id: record.get('id')
}
});
}
}
}