PDA

View Full Version : Ext.form.ComboBox not populating



arnabneogi
25 Sep 2016, 9:01 PM
Hi,
I m populating combobox using Ext.Ajax.request. This way combobox will be populated while the page loads.




this.initAjaxCall = Ext.Ajax.request({
url: 'url_of_API',
method:'GET',
scope : this,
success : function(result, request) {
var obj = JSON.parse(result.responseText);
Ext.each(obj.name,function(v){
Ext.getCmp('appCombo').getStore().add({name: v.name});
Ext.getCmp('appCombo').getStore().add({id: v.id});
});
}});

This is combobox:


this.appcombo = Ext.create('Ext.form.ComboBox', {
id : 'appCombo',
emptyText: 'Name',
typeAhead: true,
queryMode: 'local',
triggerAction: 'all',
displayField: 'name',
valueField: 'id',
store: this.appStore
});

Finally the store:


var appStore = new Ext.data.ArrayStore({
autoLoad: true,
fields : ['name','id']
});

Onready I'm populating the combox


Ext.onReady (function () {
var sampleData = [];
appStore.load(sampleData);
appcombo.render('container');

});

But the dropdown is showing blank. I can see in console the values are populating.
Please help.

arnabneogi
25 Sep 2016, 10:49 PM
It is working when 'Ext.form.ComboBox' is replaced by xtype:'combo',

Gary Schlosberg
26 Sep 2016, 1:21 PM
Glad to hear that you found your solution, and thanks for sharing. Perhaps it was a timing issue?