PDA

View Full Version : cannot populate Combo with dynamic array



raj_plays
20 Oct 2011, 10:38 AM
Hi, I am trying to populate an Ext.form.ComboBox using a dynamically created 2 - d array.
Whereas a static 2 - d array like the one below works


var messageTypecombo = new Ext.form.ComboBox({
allowBlank: false,
typeAhead: true,
triggerAction: 'all',
store: new Ext.data.SimpleStore({
fields: ['value', 'name'],
data: [
[0, 'Station Promo'],
[1, 'Program Promo'],
[2, 'Sponsor']
]
}),
mode: 'local',
displayField: 'name',
valueField: 'value'
});


The dynamic array like the one below does not. It displays only a 0 in the combo box



var messageTypesArr = [];
messageTypesArr.push([0, 'Station Promo']);
messageTypesArr.push([1, 'Program Promo']);
messageTypesArr.push([2, 'Sponsor']);

var messageTypecombo = new Ext.form.ComboBox({
allowBlank: false,
typeAhead: true,
triggerAction: 'all',
store: new Ext.data.SimpleStore({
fields: ['value', 'name'],
data: messageTypesArr
}),
mode: 'local',
displayField: 'name',
valueField: 'value'
});


Please help

raj_plays
20 Oct 2011, 1:05 PM
Found the error.
I was trying to pouplate the combo before the dynamic array had been loaded.
Silly me.

Dear Admin, please delete this thread