PDA

View Full Version : Combobox not selected value



lucasite
6 Jul 2010, 11:33 AM
Hi,
For some reason my combobox isnt selecting the right item when I open my edit form, and I cannot figure out why, its probably something silly, I just cant see it.

the store:

var myData = [
[1, 'Bank Account'],
[2, 'Savings Account'],
[3, 'Credit Card']
];

the field itself in the form:

new Ext.form.ComboBox({
id: "acctype",
name: "accountType",
store: store,
valueField: 'id',
hiddenName: 'accountTypeValue',
displayField:'name',
editable: false,
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText:'Select an account type...',
selectOnFocus:true
}),

and the actual ajax response:

{"accountName":"Checking Account","accountType":1,"startingBalance":50}

The accountName and the balance are filling in correct, the account type just doesnt seem to map, even though the value is correct, and the name = accountType.

What am I missing, any ideas?


Luca

Wesling
6 Jul 2010, 12:52 PM
I think that you forgot to post the code where "store" is defined.

lucasite
6 Jul 2010, 1:14 PM
ah yes. the store, although its very simple:


var store = new Ext.data.ArrayStore({
fields: ['id', 'name'],
data : myData
});

and Im loading the form with:

form.load({
url: "account/get",
params:{
action: "get",
itemid: this.itemid || 0
}});

But like I say, the accountname and balance populates correctly, so it must be a property issue on the combo field itself.

Wesling
6 Jul 2010, 2:07 PM
Try using accountTypeValue in your ajax response rather than accountType.


{"accountName":"Checking Account","accountTypeValue":1,"startingBalance":50}

lucasite
6 Jul 2010, 2:17 PM
Ah thats it, thanks mate.
Weird how the hiddenName property overrides the name property. I know I included that to help when posting the data.