PDA

View Full Version : Bring in value from one combobox to a second combobox to send as a param



JoeWhitlock
12 Oct 2015, 11:47 AM
I want to use the selected value from a combobox as a parm on another combobox. I can get the value selected and assign it to variable. My problem is using that value as a parm on the next combbox. I've tried a lot of different examples and nothing seems to work. Thanks for any help. My code is below.



xtype:'combo', id:'add_MTMAJMIN',

fieldLabel:'Stop Level',
emptyText: 'Select Level',
selectOnTab: true,
triggerAction: 'all',
editable: false,
forceSelection:true,
selectOnFocus: true,
valueField: 'text',
displayField: 'text',
mode: 'local',
store: new Ext.data.SimpleStore({
fields: ['text'],
data: [['Major'], ['Minor']]
}),
listeners: {
scope : this,
select: function MajMin_Select (combo, record, index)
{
var svmajmin = combo.getValue();
// alert("majmin: " + svmajmin);
}
}




xtype:'combo',
id:'add_MTREASON',
fieldLabel:'Reason',
emptyText: 'Select Reason',
selectOnTab: true,
triggerAction: 'all',
editable: false,
forceSelection:true,
valueField: 'DRREASON',
displayField: 'DRREASON',
store: new Ext.data.JsonStore({
url: 'vvcall.pgm',
fields: ['DRREASON'],
root: 'REASON',
autoLoad: false,
baseParams: {
action: 'getReasons',
pgm: 'GETREASON',
tbmajmin: svmajmin.getValue()
}
})

joel.watson
12 Oct 2015, 11:54 AM
Hi--

You could add an extraParam (http://docs.sencha.com/extjs/4.2.4/#!/api/Ext.data.proxy.Server-method-setExtraParam) to the second combo's proxy when the first combo's value changes, or even add a beforequery (http://docs.sencha.com/extjs/4.2.4/#!/api/Ext.form.field.ComboBox-event-beforequery) listener to the second combobox and influence the proxy there based on the value of the first combobox.

Thanks!
Joel

jdkhamba
16 Oct 2015, 3:59 PM
You can set the extraParams in the second combo using setProxy of the combo's store.

Take a look:
https://fiddle.sencha.com/#fiddle/vkl