PDA

View Full Version : Laborious Remote ComboBox



stephen.friedrich
17 Aug 2009, 4:49 PM
After some digging in the examples I got my remote combo box to work.
However I don't like the lengthy wire protocol.

My ComboBox does not need a distinctive valueField nor a paging mechanism.

Yet, I still have to pass this from the server


{currencyCodes:[{code:'EUR'}, {code:'USD'}, {code:'CHF'}]}and name both the "code" field and the root in the the reader and the displayField in the combo:


var currencyStore = new Ext.data.Store({
proxy : new Ext.data.HttpProxy({
url: '/acme/currency-codes'
}),
reader: new Ext.data.JsonReader(
{
root: 'currencyCodes'
},
[{name: 'code'}]
)
});

var testCombo = new Ext.form.ComboBox(
{
displayField: 'code',
...
I would rather just send this from the server:


{currencyCodes:['EUR', 'USD', 'CHF']}or even this:


['EUR', 'USD', 'CHF']What's the best way to hook into either the JsonReader or the ComboBox to make this work?

evant
17 Aug 2009, 4:54 PM
You could write a custom reader to parse the data. If you look at the source for the various readers, you'll see it's pretty simple.