Skip to content

Instantly share code, notes, and snippets.

@ricardoalcocer
Created November 23, 2012 20:27
Show Gist options
  • Save ricardoalcocer/4137144 to your computer and use it in GitHub Desktop.
Save ricardoalcocer/4137144 to your computer and use it in GitHub Desktop.
Basic Alloy : Dynamic TableView Handling + Open Window
var args = arguments[0] || {};
$.rowId.text=args.rowId;
$.itemName.text=args.itemName;
function closeme(){
$.win.close();
}
".container": {
backgroundColor: "yellow",
layout:"vertical"
},
"#itemName":{
height: Ti.UI.SIZE,
left: 0
},
"#rowId":{
height: Ti.UI.SIZE,
left: 0
},
"#closebtn":{
height: Ti.UI.SIZE,
width: Ti.UI.SIZE
}
<Alloy>
<Window id="win" class="container">
<Label id="itemName"></Label>
<Label id="rowId"></Label>
<Button id="closebtn" onClick="closeme">Close Me</Button>
</Window>
</Alloy>
function showItems(e) {
Ti.API.info(e.rowData.itemName);
var payload={
rowId:e.rowData.rowId,
itemName:e.rowData.itemName
}
var w=Alloy.createController('detailwin',payload).getView();
w.open();
}
var rowData=[];
for(var i=1;i<=10;i++){
var payload={
rowId:i,
itemName:'Test' + i
}
var row=Alloy.createController('row',payload).getView();
rowData.push(row);
}
$.itemsList.data=rowData;
$.win.open();
"#container": {
backgroundColor:"white"
}
<Alloy>
<Window id="win">
<TableView id="itemsList" onClick="showItems">
</TableView>
</Window>
</Alloy>
var args = arguments[0] || {};
$.row.rowId=args.rowId;
$.row.itemName=args.itemName;
$.itemName.text=args.itemName;
"#row":{
height: "40dp",
hasChild: true
},
"#itemName": {
width: Ti.UI.SIZE,
height: Ti.UI.SIZE,
color: "#000",
left: 0
}
<Alloy>
<TableViewRow id="row" rowId="1" itemName="Test1">
<Label id="itemName">Test 1</Label>
</TableViewRow>
</Alloy>
@TimDorand
Copy link

Thanks ! Need this in the official documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment