Skip to content

Instantly share code, notes, and snippets.

@pec1985
Created April 19, 2012 18:40
Show Gist options
  • Save pec1985/2422904 to your computer and use it in GitHub Desktop.
Save pec1985/2422904 to your computer and use it in GitHub Desktop.
Custom Table
function CustomTable(){
var self = {};
var win = Ti.UI.createWindow({
backgroundColor:'#ccc'
});
var table = Ti.UI.createTableView({
top:20,
bottom:20,
left:20,
right:20,
rowHeight:80
});
var tableData = [];
for(var i = 0, len = 20; i < len; i++){
var label = Ti.UI.createLabel({
text:'Hola desde '+i,
height:Ti.UI.SIZE,
width:Ti.UI.FILL,
customProp: (i*100)
});
var row = Ti.UI.createTableViewRow({
className:'custom_table',
backgroundColor: "#"+((1<<24)*Math.random()|0).toString(16)
});
row.add(label);
tableData.push(row);
}
table.setData(tableData);
win.add(table);
table.addEventListener('click', function(e){
alert(e.source.customProp);
});
self.Window = win;
return self;
}
module.exports = CustomTable;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment