Skip to content

Instantly share code, notes, and snippets.

@grantges
Created July 2, 2012 20:31
Show Gist options
  • Save grantges/3035526 to your computer and use it in GitHub Desktop.
Save grantges/3035526 to your computer and use it in GitHub Desktop.
Creating a tableview in appcelerator with multiple views per row
/*
* Create Your Window
*/
var win = Ti.UI.createWindow({
title: 'MainWin',
backgroundColor: '#a6a6a6'
});
/*
* Array to hold Table Data
*/
var rowData = [];
/*
* Create some Table Rows
*/
for(var i=0; i<10; i++){
var row = Ti.UI.createTableViewRow({
height: 100,
width: Ti.UI.FILL, //'auto' is deprecated as of Ti Mobile SDK v2.0 - use Ti.UI.SIZE or Ti.UI.FILL
layout: 'horizontal',
selectionStyle: Titanium.UI.iPhone.TableViewCellSelectionStyle.NONE
});
/*
* Create some default Views, add them to your TableViewRow
*/
for(var k=0; k<4; k++) {
var view = Ti.UI.createView({
height: 90,
width: 72,
left:6,
top: 5,
backgroundColor: '#ececec',
borderColor: '#000',
border: 1,
});
row.add(view);
}
/*
* Update the data array with the TableViewRow you just created
*/
rowData.push(row);
}
/*
* Create Your TableView, add the data previously created
*/
var tableView = Ti.UI.createTableView({
height: Ti.UI.FILL,
width: Ti.UI.FILL,
backgroundColor: 'transparent',
separatorColor: 'transparent',
data: rowData
});
/*
* Add the tableView to the window
*/
win.add(tableView);
win.open();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment