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

Alloy - JSON to table view row.

$
0
0

hi, first sorry for my english. i´m trying to show my json data into table view rows, i´m new at this so i really don´t know if i´m doing this right, i think not because my app is not showing the rows .

window: AmigosDN.xml

<Alloy>
    <Window>
        <View class="container">
            <Button onClick="cerrarADN" id="volver">Volver</Button>
            <TableView id="tabla" onClick="get">
 
            </TableView>
 
        </View>
    </Window>
</Alloy>
AmigosDN.tss
"#volver":{
    top:0,
    left:0,
}
".container" : {
    backgroundColor:"#00FFFF",
 
}
"#tabla":{
    top:20,
    backgroundColor:"white",
}
AmigosDN.js
var args = arguments[0] || {};
 
function cerrarADN (){
 
    $.AmigosDN.close();
}
 
function get (){
    var data = [];
    var url = "http://amigosdelnorte.com.ar/read_todo_list2.php";
    var client = Ti.Network.createHTTPClient({
     // function called when the response data is available
     onload : function(e) {
        var jsonObject = JSON.parse(this.responseText);
   // alert(JSON.stringify(this.responseText));
        for (var i = 0, j = jsonObject.resultset.length; i < j; i++) {
        alert(jsonObject.resultset[i].Local + " " + jsonObject.resultset[i].GL + " -- " + jsonObject.resultset[i].GV + " " + jsonObject.resultset[i].Visitante);
 
            var row=Alloy.createController('row', {  
            Local : jsonObject.resultset[i].Local,
            GL : jsonObject.resultset[i].GL,
            GV : jsonObject.resultset[i].GV,
            Visitante : jsonObject.resultset[i].Visitante,
            Comentario : jsonObject.resultset[i].Comentarios  
 
            }).getView();
 
            data.push(row);
 
            };
 
 
        $.tabla.setData(data);    
 
     },
     // function called when an error occurs, including a timeout
     onerror : function(e) {
         alert(this.responseText);
     },
     timeout : 5000  // in milliseconds
 });
 // Prepare the connection.
 client.open("GET", url);
 // Send the request.
 client.send();
}
Row.xml
<Alloy>
    <TableViewRow >
            <Label id="Local"/>
            <Label id="GL"/>
            <Label id="GV"/>
            <Label id="Visitante"/>
            <Label id="Comentario"/>
    </TableViewRow>
</Alloy>
row.tss
"TableViewRow":{  
 layout:"horizontal"  
}  
 
"Label":{  
 color:'#000',  
 font:{  
  fontFamily:"Ariel",  
  fontSize:'20dp',  
  fontWeight:'bold'  
 }  
}
row.js
var args = arguments[0] || {};
 
$.Local.text = args.Local;
$.GL.text = args.GL;
$.GV.text = args.GV;
$.Visitante.text = args.Visitante;
$.Comentario.text = args.Comentario;
this is my first app, so you may see some wrong things, i want to know how to do it right, help.

Viewing all articles
Browse latest Browse all 8068

Trending Articles



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