Expected Results
I should be able to read from e.row.children[] within a table's event listener. This works fine on iOS (simulator and my iPad running iOS5) and works with TiAPI 1.7.5/1.7.6 on Android.
Actual results
Code below throws
Uncaught TypeError: Cannot set property 'text' of undefined
var table = Ti.UI.createTableView();
function makeRow(num) {
var row = Ti.UI.createTableViewRow({
height:60,
rowID: num
});
row.add(Ti.UI.createLabel({
font:{
fontWeight:'bold',
fontSize:16
},
left:5,
top: 0,
text:'Row '+num
}));
row.add(Ti.UI.createLabel({
font:{
fontWeight:'normal',
fontSize:13
},
left:5,
top: 35,
text:'Subtitle for Row '+num
}));
return row;
}
for(var i=0;i<6;i++) {
table.appendRow(makeRow(i));
}
table.addEventListener('click', function(e){
e.row.children[1].text = 'You clicked row '+ e.index;
});
win1.add(table);
The sample test code doesn't work. Also e.row.children is READ-ONLY (refer to docs). Test Code:
Test Instructions: 1. Run app 2. Click on a row and you should see "Subtitle for row ..."
This issue latest notification was not sent due to JIRA mail setting. Fixed now. Please check the issue for latests changes.
e.row.children (the array) has always been read only. But the properties of the children have always been read/write. Are you closing this without action? Are properties of children now unwriteable? That is a change that will cause problems.
I totally agree with Tim. As a workaround, custom property can be added to the row:
Opening this issue based on Tim's comments. We need to address these concerns.
You can change the children properties. For example, e.row.children[0].backgroundColor = ...; The scope of this bug is to properly expose children[], not to change existing behaviors.
The scope of this ticket was that with 1.8.1 you cannot change the properties of children. The code I submitted certainly does work and demonstrate that. However, I can confirm that the code as I supplied does work on the 1.9 branch. Thus I'm fine with closing this ticket now.