Add data to a row
I have a drill down menu. Can I add data to the row so when I click on a row, I have access to it in the event? When I alert(event) in the click event I can see a bunch of information pertaining to that row so I am assuming I can. I just don't know how.
2 Answers
-
I think this is the solution, if i understand it correct:
//First create a table var table = Ti.UI.createTableView({ top:0, height: 'auto' }); //Create a row var rows = []; rows[0] = Ti.UI.createTableViewRow({ height: 'auto', id: 'yourId' //This variable isn't visible in the API's that because you can add every variable you want of an object }); //Create a label var label = Ti.UI.createLabel({ color: '#000000', text: 'Your text', top: 1, left: 1, width: 110 }); rows[0].add(label); table.setData(rows); table.addEventListener('click',function(e){ if( e.row.id == 'yourId' ) { label.text = 'You clicked on yourId'; } });
-
I've answered my own post again.
yourRow.yourCustomData = 'your data';
accessed:
event.rowData.yourCustomData