title: Titanium Alloy: Can't Get Row Data To Print To A New Row It Is Always Overwriting The Previously Written Data
body: <p>I was hoping one of you could help me figure out why my row data keeps writing to the same row and overwriting the previously written data instead of starting on a new row after every iteration. Here's what I have so far:</p>
  
  <p><em>This alloy.js file below gets the information I need for the app from the server and passes it to the <code>formateData()</code> function in the index.js file.</em></p>
  
  <p><strong>alloy.js</strong></p>
  
  <pre><code>GetDataRequest("http:somejsondata/data.json");
  
  
   function GetDataRequest(url)
   {
      var xhr = Ti.Network.createHTTPClient({             
      onload: function(e) 
      {
          Alloy.Globals.formateAnimalData(JSON.parse(xhr.responseText));
      },
  
      onerror: function(e) {
          Ti.API.debug("STATUS: " + this.status);
          Ti.API.debug("TEXT:   " + this.responseText);
          Ti.API.debug("ERROR:  " + e.error);
          alert('There was an error retrieving the remote data. Try again.');
      },
      timeout:5000
  
      });
      xhr.open("GET", url);
      xhr.send();
  }
  </code></pre>
  
  <p><strong>index.js</strong></p>
  
  <pre><code>var appData = [];
  
  Alloy.Globals.formateAnimalData = function(data)
  {   
      console.log("I was also called");
      for (var i = 1; i &lt;=8; i++)
      {
          var row = {
              name: data.animals[i].name,
              animal: data.animals[i].animal,
              food: data.animals[i].food
          };
          appData.push(Alloy.createController('index', row).getView());
          //console.log(appData); 
      }
  };
  
  var args = arguments[0] || {};
  
  $.name.text = args.name || '';
  $.animal.text = args.animal || '';  
  $.food.text = args.food || '';
  
  
  $.table.setData(appData);
  $.index.open();
  </code></pre>
  
  <p><strong>index.xml</strong></p>
  
  <pre><code>&lt;Alloy&gt;
      &lt;TabGroup id='index'&gt;
          &lt;Tab title="Tab 1" icon="KS_nav_ui.png"&gt;
              &lt;Window id='main' class='' title="Zoo"&gt;
                  &lt;TableView&gt;
                      &lt;TableViewRow id='table'&gt;
                          &lt;Label id ='name'   class ='label'&gt;&lt;/Label&gt;
                          &lt;Label id ='animal' class ='label'&gt;&lt;/Label&gt;
                          &lt;Label id ='food'   class ='label'&gt;&lt;/Label&gt;             
                      &lt;/TableViewRow&gt;
                  &lt;/TableView&gt;
              &lt;/Window&gt;
          &lt;/Tab&gt;
      &lt;/TabGroup&gt;
  &lt;/Alloy&gt;
  </code></pre>
  
  <p>I should note that the:</p>
  
  <pre><code>$.table.setData(appData);
  </code></pre>
  
  <p>line in the index.js file doesn't work. The data still prints to the screen even if this line is not in there. The reason for this I think is because the following line:</p>
  
  <pre><code>appData.push(Alloy.createController('index', row).getView());
  </code></pre>
  
  <p>is not pushing a row of objects into the <strong>appData array</strong> and infact when I log the contents of the appData array to the screen I get:</p>
  
  <pre><code>           (
  [INFO] :       "[object index]",
  [INFO] :       "[object index]",
  [INFO] :       "[object index]",
  [INFO] :       "[object index]",
  [INFO] :       "[object index]",
  [INFO] :       "[object index]",
  [INFO] :       "[object index]",
  [INFO] :       "[object index]"
  [INFO] :   
             )
  </code></pre>
  
  <p>I am just trying to get it so that it prints the animals: Name, Type and Food Preference to row 1 and the next animals Name, Type and Food Preference to row 2 and so on.</p>