Problem
While using deleterow() method in TableView it always delete the first row (does not matter what index number we put).
Regression - works fine with SDK 1.7.5
Reproducible Steps
1. Run the above code
2. Press last row named "goodgirl"
Sample Code
var win = Ti.UI.createWindow({
title : 'xmas'
});
var table = Ti.UI.createTableView({
title : 'just a test'
});
win.add(table);
win.open();
var data = ['goodday', 'goodtime', 'goodboy', 'goodgirl'];
var arr = [];
for(var i = 0, max = data.length; i < max; i++) {
arr[i] = Ti.UI.createTableViewRow({
title : data[i],
name : data[i]
});
}
table.setData(arr);
table.allrows = arr;
for(var j = 0, len = table.allrows.length; j < len; j++) {
table.allrows[j].addEventListener('click', function(e) {
var index = table.getIndexByName(e.rowData.name);
Ti.API.info(index);
//alert(table.data[0].rowCount);
table.deleteRow(index);
});
}
The problem is also reproducable in the KitchenSink table_view_row_delete.js. It should delete the last row, but deletes the first. Note that tableview.data.length gives 1 instead of 5. This seems another 1.8.0.1 bug to me. Is it counting sections instead of rows?
Yep, i can confirm that. Same here. Seems to count the sections
I confirm this too.
Pull request ready https://github.com/appcelerator/titanium_mobile/pull/1115
Closing bug. Verified fix on: SDK build: 1.9.0.v20120111233134 Runtime: V8, Rhino Titanium Studio, build: 1.0.8.201201111843 Device: Droid 3 (2.3.4)
Seems to me this works for Android 2.3.3 but not for Android 2.2