Skip to content

Instantly share code, notes, and snippets.

@minhnc
Created February 10, 2012 23:28
Show Gist options
  • Save minhnc/1793973 to your computer and use it in GitHub Desktop.
Save minhnc/1793973 to your computer and use it in GitHub Desktop.
Titanium Custom Row
function populateData() {
var currentWin = Ti.UI.createWindow();
var table = Ti.UI.createTableView();
var tableData = [];
var rows = [
{title: 'Title 1', start_dt: 'start_dt 1', hasChild: true},
{title: 'Title 2', start_dt: 'start_dt 2', hasChild: true},
{title: 'Title 3', start_dt: 'start_dt 3', hasChild: true},
{title: 'Title 4', start_dt: 'start_dt 4', hasChild: true},
{title: 'Title 5', start_dt: 'start_dt 5', hasChild: false},
{title: 'Title 6', start_dt: 'start_dt 6', hasChild: false},
{title: 'Title 7', start_dt: 'start_dt 7', hasChild: false}
];
for(var i = rows.length - 1; i >= 0; i--) {
var row = Titanium.UI.createTableViewRow({
height : '60dp',
backgroundColor : '#ffffff',
hasChild : true,
path : 'sessDet.js'
});
var nameLabel = Ti.UI.createLabel({
text : rows[i].title,
font : {
fontSize : '15dp',
fontWeight : 'bold'
},
});
var start = Ti.UI.createLabel({
text : rows[i].start_dt,
font : {
fontSize : '16dp'
},
height : 'auto',
left : '15dp',
bottom : '5dp',
color : '#000',
});
row.add(nameLabel);
row.add(start);
row.hasChild = rows[i].hasChild;
row.className = 'event_row';// Should have className for better performance
tableData.push(row);
};
table.setData(tableData);
currentWin.add(table);
currentWin.open();
};
// In some place
populateData();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment