PDA

View Full Version : Combo posting Text now not ID - WTF???



PCSpectra
14 Jun 2010, 8:13 AM
I have several combo controls thorughout my application all of which looks something like:




{
xtype: 'combo',
fieldLabel: 'Station',
anchor: '95%',


id: 'id_combo_station',


value: station,
queryParam: 'station',
hiddenName: 'id_station',
hiddenValue: id_station,


minChars: 1,
allowBlank: false,
triggerAction: 'all', // Show drop down even when no text entered
selectOnFocus: true,


valueField: 'id_primary',
displayField: 'name',


store: new Ext.data.ArrayStore({
fields:[{name: 'id_primary', mapping: 'id_primary'}, {name: 'name', mapping: 'name'}],


proxy: new Ext.data.HttpProxy({
url: 'services/index.php/system/station/list'
})
})
}



This exact code works ifne on other combos but for whatever reason this one has deided to post the textual value of the combo instead of the ID as expected. This only appears to happen on updating (creating workes fine).


On other observation, is when updating as long as I re-select the item from the combo and then submit the ID is properly sent to the server. Obviously this is unaccetable for any end user. I have no idea why this stopped working as expected...what could I have changed to cause this annoying affect/feature?


No where is id_station being overridden. In fact I echo it out immediately before being passed to combo control and the output is as expected.


Cheers,
Alex

Animal
14 Jun 2010, 9:42 AM
ArrayStore? With string mappings?

crysfel
14 Jun 2010, 10:04 AM
I think you should use the JsonStore :)

PCSpectra
14 Jun 2010, 10:48 AM
ArrayStore? With string mappings?

I don't see anything technically wrong with that, is there? I didn't use JsonStore simply because I was ujnder the impression it owuld be slightly heavier as an object and required additional formatting of the data (json_encode) before being sent to the client???

Not to mention most comboboxes have no need for additional data such as record count that lists which support paginatation do.

This technique has worked fine on dozens of other combo's so why this one is acting up now...

EDIT | I actually just had a hunch and tried it and sure as shoot that fixed the problem.

I was setting the focus to the first control of every form and this somehow causes the text value to be sent to server not the ID. Removing out the code fixed the issue.

Cheers,
Alex

Animal
14 Jun 2010, 12:03 PM
ArrayStore.

You are using an ArrayReader to read a Array.

And using string mapping. You coded the mapping config, so do you understand what it does?