• If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Announcement

Collapse
No announcement yet.

vvOut.buffer = 1

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • vvOut.buffer = 1

    I'm trying to load two stores at one time. I've done this in previous releases but I can't seem to get it to work now. The response does show both stores are there, so it appears the vvOut_execSQLtoJSON procedures are working fine. On the front end I do the following:

    onStoreLoad: function(store, records, successful, operation, eOpts) {
    if(successful === true){
    var sg = Ext.getStore('Sgslshsts');
    sg.loadRawData(sg.getProxy().getReader().rawData);
    }
    }

    In doing some research, I found I might need a property of keepRawData: true in the reader object. I tried that too but no change.

    The onStoreLoad function is inside the store definition. When I do a this.getStore('Contracts').load() it returns the data for contracts and the other store I'm trying to load at the same time (Sgslshsts). I see the records in the console but they are not loading to the grid. When I console.log the Sgslshsts store in the function after the loadRawData it's empty.

    Any ideas?

  • #2
    Easiest way is to use a view model. You can bind the data property of the store. Suppose I have a response that returns back an array of "customers" and an array of "orders".

    View model store definitions
    Code:
    stores: {
       Customers : {
           fields : ['NAME',ADDR'],
           data : '{customerData}'
       },
       Orders : {
           fields : ['NUM','TOTAL'],
           data  : '{orderData}'
       }
    }
    Loading the data
    Code:
    Ext.Ajax.request({
       url : '/valence/vvcall.pgm',
       params : {
          pgm : 'MY_PGM',
          action : 'myAction'
       },
       scope   : me,
       success : function(r){
           var d = Ext.decode(r.responseText);
           me.getViewModel().set({
             customerData : d.customers,
             orderData : d.orders
           });
       }
    })

    Comment


    • #3
      Based on your example source I would think you would want to get the contracts store raw data. "store.getProxy().getReader().rawData"

      Sean is suggesting the easier way in my opinion however if you need to do it off the load of the store here is an example;

      Code:
      var statusStore  = Ext.create('Ext.data.Store', {
              proxy: {
                  type  : 'memory',
                  reader: {
                      type: 'json'
                  }
              }
          }),
          contractStore = Ext.create('Ext.data.Store', {
              autoLoad : true,
              proxy    : {
                  type  : 'ajax',
                  url   : 'myData.json',
                  reader: {
                      type        : 'json',
                      rootProperty: 'contracts',
                      keepRawData : true
                  }
              },
              listeners: {
                  load: function (str, recs) {
                      statusStore.setData(str.getProxy().getReader().rawData.statuses);
                  }
              }
          });
      Example Data for myData.json
      Code:
      {
        "contracts":[{
          "id":1,
          "name":"Acme"
          },{
          "id":2,
          "name":"CNX"
          }],
        "statuses":[{
          "id":1,
          "name":"Active"
         }, {
          "id":2,
          "name":"Held"
        }]
      }
      Sencha Fiddle

      Comment


      • #4
        Thanks! I'll experiment. I have a feeling it's because my store definition doesn't have it defined as a memory type store.

        Comment

        Working...
        X