I am having trouble passing data to the next table/window. How can I get the ID to pass to the next window?
var win = Ti.UI.currentWindow; var db = Ti.Database.install('../2012.sqlite', 'codesTable'); function setArray() { var rows = db.execute('SELECT DISTINCT category, categorySubtitle FROM codes ORDER BY categorySubtitle'); var id = Ti.UI.currentWindow.id; // create the array var dataArray = []; while (rows.isValidRow()) { var id = rows.fieldByName('id'); var row = Ti.UI.createTableViewRow({ backgroundColor : 'transparent', height : 60, hasChild : true, path : '../products/producs2.js', }); var lblTitle = Ti.UI.createLabel({ text : rows.fieldByName('category'), top : 5, left : 45, width : 250, height : 20 }); row.add(lblTitle); var lblDesc = Ti.UI.createLabel({ text : rows.fieldByName('categorySubtitle'), top : 30, left : 45, width : 215, bottom : 10, font : { fontSize : 12 } }); row.add(lblDesc); dataArray.push(row, id); rows.next(); }; // set the array to the tableView tableview.setData(dataArray); }; // create table view var tableview = Ti.UI.createTableView({ }); tableview.addEventListener('click', function(e) { if (e.rowData.path) { var win = Ti.UI.createWindow({ url : e.rowData.path, title : e.rowData.title, id: e.rowData.id }); Ti.UI.currentTab.open(win); } }); setArray() win.add(tableview);
1 Answer
Accepted Answer
Hi Mike
You are very close, you need to add the id to the row.
var row = Ti.UI.createTableViewRow({ ... id: id, ... });Or
var row = Ti.UI.createTableViewRow({ ... id: rows.fieldByName('id');, ... });You can then retrieve this later using;
var id = Ti.UI.currentWindow.id;
Your Answer
Think you can help? Login to answer this question!