title: ExtJS 4.2 - Error Loading Store From Command - Data Returned From Service - MVC Setup
body: <p>I am having all sorts of issues learning ExtJS (I am a flex Dev). Currently, I am unsure how to load a store from a command. I have a command where I make a service call and get the data. I then want to load the model with this data (from inside the command).</p>
  
  <p>My code...</p>
  
  <p>PhoneCallsLoadCommand.js:  (COMMAND)</p>
  
  <pre><code>Ext.define('DG.controller.PhoneCallsLoadCommand', {
      extend: 'Ext.app.Controller',
      stores: ['PhoneCalls'],
      models: ['PhoneCall'],
  
      views: [
          'PhoneCallListView'
      ],
  
      init: function () {
          var url2 = "https://MyServiceURLWSDL";
          var pl = new SOAPClientParameters();
          pl.add("arg0", false);
  
          SOAPClient.invoke(url2, "gePaymentsMethod", pl, true, getDataCallback);
  
          function getDataCallback(response) {
          // This is where I want to load the response data into the Model
              var store = Ext.getStore('phoneCallsStore');
              store.loadData(response);
          }
      }
  });
  </code></pre>
  
  <p>Here is the response XML data returned from the service call:</p>
  
  <pre><code>&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"&gt;
     &lt;soapenv:Body&gt;
        &lt;dlwmin:getPaymentsMethod xmlns:dlwmin="http://blahblah.com/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
           &lt;return&gt;
              &lt;contents&gt;
                 &lt;eftAcctNo&gt;501014635986&lt;/eftAcctNo&gt;
                 &lt;empSsn&gt;122400724&lt;/eftAcctRoutNo&gt;
              &lt;/contents&gt;
              &lt;contents&gt;
                 &lt;eftAcctNo&gt;&lt;/eftAcctNo&gt;
                 &lt;empSsn&gt;&lt;/eftAcctRoutNo&gt;
              &lt;/contents&gt;
              &lt;contents&gt;
                 &lt;eftAcctNo&gt;&lt;/eftAcctNo&gt;
                 &lt;empSsn&gt;&lt;/eftAcctRoutNo&gt;
              &lt;/contents&gt;
              &lt;status&gt;0&lt;/status&gt;
           &lt;/return&gt;
        &lt;/dlwmin:getPaymentsMethod&gt;
     &lt;/soapenv:Body&gt;
  &lt;/soapenv:Envelope&gt;
  </code></pre>
  
  <p>I need to populate this response data into my model so that I can use it in my grid.</p>
  
  <p>PhoneCall.js:  (MODEL)</p>
  
  <pre><code>Ext.define('DG.model.PhoneCall', {
      extend: 'Ext.data.Model',
      config: {
          idProperty: 'phoneCallModel',
          fields: [
              {name: "eftAcctNo", type: "string"},
              {name: "empSsn", type: "string"}
          ]
      }
  });
  </code></pre>
  
  <p>PhoneCalls.js  (STORE)</p>
  
  <pre><code>Ext.define('DG.store.PhoneCalls', {
      extend: 'Ext.data.Store',
      config: {
          storeId: 'phoneCallsStore',
          model: 'DG.model.PhoneCall',
          autoLoad: false
      },
      proxy: {
          type: 'memory',
          reader: {
              type: 'xml',
              record: 'contents',
              //rootProperty: 'return'
          }
      },
      listeners: {
          'load' : function() {
              console.log("Making Service Call...");
          }
      }
  });
  </code></pre>
  
  <p>In the Command, when I do this:</p>
  
  <pre><code>var store = Ext.getStore('phoneCallsStore');
              store.loadData(response);
  </code></pre>
  
  <p>I get the following error: 
  Uncaught TypeError: Cannot call method 'loadData' of undefined</p>
  
  <p>Can someone tell me how to load that response data into the model? My View is a grid that points to the model.</p>
  
  <p>PhoneCallListView.js  (VIEW)</p>
  
  <pre><code>Ext.define('DG.view.PhoneCallListView' ,{
      extend: 'Ext.grid.Panel',
      alias: 'widget.phoneCallListView',
      title: 'Phone Calls DataGrid',
  
      // we no longer define the Phone Calls store in the 'initComponent' method
      store: 'PhoneCalls',
  
      initComponent: function() {
          this.columns = [
              {header: 'Eft Acct No', dataIndex: 'eftAcctNo', flex:1},
              {header: 'Emp Ssn', dataIndex: 'empSsn', flex:1},
          ];
  
          this.callParent(arguments);
      }
  });
  </code></pre>
  
  <p>FYI - I wasn't able to get the Store to make the service call using the ajax proxy, so I found it easy to use soapclient.js.
  Thanks</p>