PDA

View Full Version : how can I get the selected value in comboBox



Supersuper
5 Jul 2007, 1:16 PM
I try to use "crapCombobox.getValue()", but it return nothing. I wonder where did I did wrong. Also it can only allow me to pick the first one, I can't pick any others.




rec = Ext.data.Record.create([
{name: 'name', type:'string'},{value: 'value', type:'string'}
]);

sto = new Ext.data.SimpleStore({
fields: ['name','value'],
data:rec
});

sto.add(new rec({name: '(Select One0)'},{value: '(Select One)'}));
sto.add(new rec({name: '(Select One1)'},{value: '(Select One)'}));
sto.add(new rec({name: '(Select One2)'},{value: '(Select One)'}));
sto.add(new rec({name: '(Select On23)'},{value: '(Select One)'}));


crapCombobox = new Ext.form.ComboBox({
fieldLabel: 'Crop',
name: 'CropID',
store: sto,
hiddenName: 'CropID',
displayField: 'name',
valueField: 'value',
typeAhead:true,
mode:'local',
triggerAction: 'all',
emptyText: '(Select One)',
selectOnFocus: true,
width: 220
});

ToNiC
7 Jul 2007, 1:22 PM
Your suppling multiple hash's per record. try this instead:


sto.add(new rec({name: '(Select One0)', value: '(Select One)'}));
sto.add(new rec({name: '(Select One1)', value: '(Select One)'}));
sto.add(new rec({name: '(Select One2)', value: '(Select One)'}));
sto.add(new rec({name: '(Select On23)', value: '(Select One)'}));