Skip to content

Instantly share code, notes, and snippets.

@hal-gh
Created November 8, 2010 04:57
Show Gist options
  • Save hal-gh/667398 to your computer and use it in GitHub Desktop.
Save hal-gh/667398 to your computer and use it in GitHub Desktop.
// create table view data object
var data = [
{title:'Row 1', hasChild:true, color:'red', selectedColor:'#fff'},
{title:'Row 2', hasDetail:true, color:'green', selectedColor:'#fff'},
{title:'Row 3', hasCheck:true, color:'blue', selectedColor:'#fff'},
{title:'Row 4', color:'orange', selectedColor:'#fff'},
{title:'Row 5', color:'orange', selectedColor:'#fff'},
{title:'Row 6', color:'orange', selectedColor:'#fff'},
{title:'Row 7', color:'orange', selectedColor:'#fff'},
{title:'Row 8', color:'orange', selectedColor:'#fff'},
{title:'Row 9', color:'orange', selectedColor:'#fff'},
{title:'Row 10', color:'orange', selectedColor:'#fff'},
{title:'Row 11', color:'orange', selectedColor:'#fff'},
{title:'Row 12', color:'orange', selectedColor:'#fff'},
{title:'Row 13', color:'orange', selectedColor:'#fff'},
{title:'Row 14', color:'orange', selectedColor:'#fff'},
{title:'Row 15', color:'orange', selectedColor:'#fff'},
{title:'Row 16', color:'orange', selectedColor:'#fff'},
{title:'Row 17', color:'orange', selectedColor:'#fff'}
];
// create table view
var tableview = Titanium.UI.createTableView({
data:data,
moving:false
});
// create table view event listener
tableview.addEventListener('click', function(e)
{
// event data
var index = e.index;
var section = e.section;
var row = e.row;
var rowdata = e.rowData;
Ti.API.info('detail ' + e.detail);
Titanium.UI.createAlertDialog({title:'Table View',message:'row ' + row + ' index ' + index + ' section ' + section + ' row data ' + rowdata}).show();
});
// add table view to the window
Titanium.UI.currentWindow.add(tableview);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment