Search code examples
javascriptextjsgridpaneljsonstore

Ext Js - How to Reference Store Values


I'm trying to read grid values from within a load event of my form. The ordersStore.load() loads my grid with data, but I don't get a record returned using getAt. Is there a better way to do this? Thanks.

client_form.on({
   actioncomplete: function(form, action){
      if(action.type === 'load'){
      var suite_no = action.result.data.suite_no;
      ordersStore.baseParams.suite_no = suite_no;
      ordersStore.load();
      var orderRec = Ext.data.Record.create(['order_id', 'suite_no', 'merchant', 'track_no', 'invoice_no', {name:'total',type: 'float'},  {name:'weight',type: 'float'}, 'status']);
      var orderRec = ordersStore.getAt(0);
      Ext.Msg.alert('rec=', orderRec);
         }
    }
});                                                 

Solution

  • The problem is that ordersStore.load() is asynchronous (the docs say-so). The data will arrive at a later point, and is not available immediately after (where you're looking for it).

    You need to add a 'load' event handler. In that function, you can examine your data since it will be loaded at that time.