PDA

View Full Version : Combobox submitted data



christ1an
5 Nov 2007, 9:17 AM
Hello,

for a while i am trying to change the value that is submitted by a combobox to the id of the option, not the text (its only for display).

so my combobox looks like this:

field = new Ext.form.ComboBox({
store: new Ext.data.Store({
proxy: new Ext.data.HttpProxy(
{url: loadURL,
headers: {'X-Dataforge-Actionhandler': 'JSON'}
}),
reader: new Ext.data.JsonReader({
totalProperty: 'results',
root:'items',
id: "id"
}, [{name: 'value'}])
}),
forceSelection : true, //true to restrict the selected value to one of the values in the list
displayField:'value',
typeAhead: true,
mode: 'local', //'remote'
triggerAction: 'all',
emptyText:'Select...',
loadingText:'Loading...',
selectOnFocus:true
});
field.store.load();

my json with the options looks like this:


{"items":[{"id":"1","value":"1: number1"},{"id":"2","value":"2: number2"},{"id":"3","value":"3: number3"},{"id":"4","value":"4: number4"}],"results":4}

when i submit the form, the "value" part will be submitted, but i want the "id" of the selected item.

how do i have to configure the JsonReader, am i right this way?

do i have to write a new renderer? when, how?

Thanks in advance, Chris



edit:


displayField:'value',
valueField : 'id',

...these are your friends, christian!