View Full Version : Combobox not selected value

6 Jul 2010, 11:33 AM
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',
editable: false,
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText:'Select an account type...',

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?


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

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:

url: "account/get",
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.

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

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

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.