Mobile: How-to show a detail view when klicked ?
Hi there!
How can i define a window/view as a detail view for an entry in my table and how do i link it to the "hasDetail" button?
Here's my code:
TableRow:
var tableRow = Titanium.UI.createTableViewRow({
hasDetail: true
});
TableView:
var topTable = Titanium.UI.createTableView({
style: Titanium.UI.iPhone.TableViewStyle.PLAIN,
headerTitle: win1.contentTitle,
data: [tableRow]
});
Would be nice to get a little "tutorial" for this!
2 Answers
-
Accepted Answer
tableview.addEventListener('click', function(e)
{
// event data
var index = e.index;
var section = e.section;
var row = e.row;
var rowdata = e.rowData;
Titanium.API.info("row - row index = "+row+", row section = "+row);
Titanium.UI.createAlertDialog({title:'Table View',message:'row ' + row + ' index ' + index + ' section ' + section + ' row data ' + rowdata}).show();
});you have to add a click event to the tableview, inside you get various parameters from the row you clicked. depending on the current index you can create and open different windows. look into the kitchensink examples starting with table_view… and those starting with window…
-
Hi Michael
Just adopting Christian's starting point below, you can link the creation of a new window to a row's
hasDetail
property in the following way:topTable.addEventListener('click', function(e) { if(e.row.hasDetail) { // open a detail window var win = Ti.UI.createWindow({url:'detailWindow.js'}); // provide access to this row's data win.rowData = e.rowData; Ti.UI.currentTab.open(win); } // else do nothing });
Good luck!