12-29-2012 12:54 PM
I'm downloading data through a rest call in the form of json and sometimes a few data items are incomplete.For example lets says I get this data:
[
{"name":"Andrew","email":"andrew@test.com"},
{"name":"Haley","email":"haley@test.com"},
{"name":"Mark"},
{"name":"Stephanie","email":"stephanie@test.com"}
]
For some weird reason when I put this data into a ListView, the datamodel will automatically fill in non-existent data with data from another item (i.e. "Mark" has no email in the data, but the ListView will show his email as "haley@test.com"). Has anyone else experienced this problem? And is there a way to fix it?
12-29-2012 01:54 PM
I was thinking I could also go through and populate non-existent values by doing something like the following:
onDataLoaded: {
dataModel.clear();
for (var i=0;i<data.length;i++)
{
if (data[i].contains("email") == false)
{
data[i].insert({"email":"no email available"});
}
}
dataModel.insertList(data);
}however this doesn't work. I'm thinking is has something to do with .contains().