bowa
16 Oct 2007, 7:05 AM
Ext.myData.array1 = [
['AL', 'Alabama'],
['AK', 'Alaska'],
['AZ', 'Arizona'],
['AR', 'Arkansas'],
['CA', 'California'],
['CO', 'Colorado'],
['CT', 'Connecticut']
];
var myStore = new Ext.data.SimpleStore({
fields: ['short','name'],
data: Ext.myData.array1
});
var myCombo = new Ext.form.ComboBox({
store: paperStore,
displayField: 'name',
triggerAction: 'all',
selectOnFocus: true,
mode:'local',
grow: true,
editable: false,
emptyText: 'choose ...'
});
myCombo.applyTo('test-combo');
The above code works, the data is a simple array
Now in fact i get my data from a DWR call (and i tried with a DWRProxy and that worked smoothly)
But because i have to use the data in multiple combo boxes and i don't want to make an ajax roundtrip for each of them, i store the response locally.
For the example i just created an object to simplify things.
Ext.myData.object1 = [
{name:'One', child: {id:1, age: 3, color: 'yellow'}},
{name:'two', child: {id:6, age: 12, color: 'blue'}},
{name:'three', child: {id:5, age: 9, color: 'red'}}
];
var myStore = new Ext.data.SimpleStore({
fields: ['short','name'],
data: Ext.myData.object1
});
var myCombo = new Ext.form.ComboBox({
store: paperStore,
displayField: 'name',
triggerAction: 'all',
selectOnFocus: true,
mode:'local',
grow: true,
editable: false,
emptyText: 'choose ...'
});
myCombo.applyTo('test-combo');
Now this does not give any errors, there are three 'empty' elements in my combo box list ...
What is the correct way to map an object into a Store?
['AL', 'Alabama'],
['AK', 'Alaska'],
['AZ', 'Arizona'],
['AR', 'Arkansas'],
['CA', 'California'],
['CO', 'Colorado'],
['CT', 'Connecticut']
];
var myStore = new Ext.data.SimpleStore({
fields: ['short','name'],
data: Ext.myData.array1
});
var myCombo = new Ext.form.ComboBox({
store: paperStore,
displayField: 'name',
triggerAction: 'all',
selectOnFocus: true,
mode:'local',
grow: true,
editable: false,
emptyText: 'choose ...'
});
myCombo.applyTo('test-combo');
The above code works, the data is a simple array
Now in fact i get my data from a DWR call (and i tried with a DWRProxy and that worked smoothly)
But because i have to use the data in multiple combo boxes and i don't want to make an ajax roundtrip for each of them, i store the response locally.
For the example i just created an object to simplify things.
Ext.myData.object1 = [
{name:'One', child: {id:1, age: 3, color: 'yellow'}},
{name:'two', child: {id:6, age: 12, color: 'blue'}},
{name:'three', child: {id:5, age: 9, color: 'red'}}
];
var myStore = new Ext.data.SimpleStore({
fields: ['short','name'],
data: Ext.myData.object1
});
var myCombo = new Ext.form.ComboBox({
store: paperStore,
displayField: 'name',
triggerAction: 'all',
selectOnFocus: true,
mode:'local',
grow: true,
editable: false,
emptyText: 'choose ...'
});
myCombo.applyTo('test-combo');
Now this does not give any errors, there are three 'empty' elements in my combo box list ...
What is the correct way to map an object into a Store?