Created
April 19, 2012 18:40
-
-
Save pec1985/2422904 to your computer and use it in GitHub Desktop.
Custom Table
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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