Results 1 to 3 of 3

Thread: Assign a combo box values after store is loaded

  1. #1
    Sencha User
    Join Date
    Jul 2012
    Posts
    53
    Vote Rating
    0
      0  

    Default Assign a combo box values after store is loaded

    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
    Code:
    ,{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.

  2. #2
    Sencha User sword-it's Avatar
    Join Date
    May 2012
    Location
    Istanbul
    Posts
    1,335
    Answers
    124
    Vote Rating
    93
      0  

    Default

    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:

    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().
         }}
    sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.

  3. #3
    Sencha User
    Join Date
    Jul 2012
    Posts
    53
    Vote Rating
    0
      0  

    Default

    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.
    Code:
      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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •