Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Quick Question: How to access objects from inside a for statement and edit them

$
0
0

Hi,

How can i get a property from an object that is in a for statement? Below is my code and right at the end is how i'm trying to fetch the data. I also need to be able to change the data such as the text in the name object.

var fatData = [
    { "name": "Matt", "myLocation" : "IN" },
    { "name": "Darby", "myLocation" : "IN" },
    { "name": "Terence", "myLocation" : "IN" },
    { "name": "Tom", "myLocation" : "OUT" },
    { "name": "Chris", "myLocation" : "OUT" }
],
thinData = [],
item,
i = -1;
 
for (var i in fatData){
    var row = Ti.UI.createTableViewRow({
        className: fatData[i].name, // improves table performance
        selectedBackgroundColor:'transparent',
        height:70,
        width:300
    });
 
    var name = Ti.UI.createLabel({
        text:fatData[i].name,
        color:'white',
        font:{fontSize:18,fontFamily:'HelveticaNeue-Bold'},
        left:50
    });
    row.add(name);
    thinData.push(row);
}
 
var people = Ti.UI.createTableView({
    backgroundColor:'transparent',
    separatorColor:'transparent',
    data:thinData,
    top:114,
    width:300
});
main.add(people);
 
// THIS IS THE BIT I'M GUESSING
 
while( thinData[i] ){
    if(thinData[i].row.name.text == user){
        alert(thinData[i].row.name.text);
    }
    i++;
}

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>