PDA

View Full Version : Assign a combo box values after store is loaded



evs.saad
4 Feb 2013, 9:40 AM
Hi,
I have a grid in which I have a combo box. I have given a facility of searching through a popup in this grid. When the user clicks on search the popup appears and the user can search the data and then select the desired result. While the desired result is selected I want to populate my combo box in the main grid.The store is loaded in the function and it returns the desired result but I could not find a way how to reassign those values to the combo box. Here is my code for the combo and the result that loads in the function


,{xtype:'label',text:' ORDER#:'},{xtype:'combo',name:'order',width:130} // this is the field with type combo

// this is the store in the function which I load and get the values
var storeOrder=Ext.create('Ext.data.Store',{fields:[{name:'order',type:'string'}],autoLoad:true,proxy:{type:'ajax',reader:{type:'json',root:'results'},url:'ajax/manage_list.php?mode=LoadOrders',extraParams:{id:rec.data.orderid}},
listeners: {
'load' : function(store,records,options) {
// here I want to assign the returned value to combo box.
}
}});
Can anyone help.Thanks in advance.

sword-it
4 Feb 2013, 2:44 PM
Hi,
Actually you are in a good way to implement this one, you just need to load the combo store from the listener that you created. Review the following code:



listeners: {
'load' : function(store,records,options) {
// here I want to assign the returned value to combo box.
// you just need to get that combobox & load the data into its store. something like below:
var combo = Ext.getCmp('combo-Id');
combo.store.loadData(records); // you need to be sure that the root defined in the combo store will match to the data that you are loading by loadData().
}}

evs.saad
5 Feb 2013, 4:00 AM
Thanks for the reply. I have tried to use the code you just mentioned but it is not working. It is giving me this error.


var combo = Ext.getCmp('orders'); combo.store.loadData(records);

But the data is not loading and I am returning the data json encoded. Do I have to
decode and then assign the values.
Thanks