hi, i have a tableview contains list of persons' name retrieved from remote database. when i click on each row of my tableview, i want to display some other data from remote database (the activity of each person of my list). i used a php web services to do this. i used a loop "For" to display data, but the problem that when i click on a row all data (all activity of persons are displayed). i tried to do this whitout loop, i can display now only one data (on click, only the activity of the first person is displayed for all rows of my tableview). i do not know what exacly should i put as condition or witch loop must be used for this. here is my code : list.js :
function doSomething(e) {
var sendit = Ti.Network.createHTTPClient({
onerror: function(e){
Ti.API.debug(e.error);
alert('There was an error during the connection');
},
timeout:5000,
});
sendit.open('GET', 'http://10.0.2.2/list.php');
sendit.send();
//Function to be called upon a successful response
sendit.onload = function(){
var json = JSON.parse(this.responseText);
var json = json.activity;
//if the database is empty show an alert
if(json.length == 0){
alert('The database row is empty');
}
var dataArray = [];
for( var i=0; i<json.length; i++){
var alertDialog = Titanium.UI.createAlertDialog({
title: 'Info Participant',
message: json[i].activity,
buttonNames: ['Accept','Reject'],
cancel: 1
});
alertDialog.show();
dataArray.push(alertDialog);
};
};
}
and this is my list.xml :
<Alloy>
<TabGroup id="mainTabGroup">
<Tab id="tab3" onClick="getTodoList">
<Window id="readWin">
<TableView id="tableView" onClick="doSomething"/>
</Window>
</Tab>
</TabGroup>
</Alloy>