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

how to bind asynchronous data to control in alloy

$
0
0

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?

Viewing all articles
Browse latest Browse all 8068

Trending Articles



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