when i asynchronously get data and bind the data to control in alloy , the control can not display my data. below is my code:
view:
<Collection src="tasklog"/> <ScrollView layout="vertical"> <TableView backgroundColor="yellow" id="taskLogList" dataCollection="tasklog" dataTransform="transformTaskLog"> <TableViewRow title="{taskLogSummary}" ></TableViewRow> </TableView> </ScrollView>controller:
//this function will get data asynchronously logs.getTaskLogs(taskId, function(success) { var arrLog = success.responseText['taskLogs']; for(var i = 0; i < arrLog.length; i++) { logs.add({ tasklogId : arrLog[i].taskLogId, taskLogSummary : arrLog[i].taskLogSummary }); } }, function(failed) { }); function transformTaskLog(model){ var transform = model.toJSON(); return transform; }when I modify controller code to below?synchronously? ,my control can display the data:
//get data synchronously logs.add({ tasklogId : 111, taskLogSummary : "ddddddddddddd" }); logs.add({ tasklogId : 222, taskLogSummary : "fffffffffffffffffff" }); function transformTaskLog(model){ var transform = model.toJSON(); return transform; }but I must get data from web service ,the opration is asynchronous.How do I resolve the problem???can Titanium.Network.HTTPClient be used synchronously?