[TIMOB-11683] iOS: TableView - implement deleteRow(TableViewRowProxy)
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2012-11-20T18:00:14.000+0000 |
Affected Version/s | Release 2.1.3 |
Fix Version/s | Release 3.1.0, 2012 Sprint 23 API, 2012 Sprint 23 |
Components | iOS |
Labels | api, module_tableview, parity, qe-testadded |
Reporter | Ping Wang |
Assignee | Ping Wang |
Created | 2012-11-07T01:38:22.000+0000 |
Updated | 2014-06-19T12:43:51.000+0000 |
Description
Steps To Reproduce:
1. Run test code below
Ti.UI.backgroundColor = 'white';
var win = Ti.UI.createWindow();
var sectionFruit = Ti.UI.createTableViewSection({ headerTitle: 'Fruit' });
sectionFruit.add(Ti.UI.createTableViewRow({ title: 'Apples' }));
sectionFruit.add(Ti.UI.createTableViewRow({ title: 'Bananas' }));
sectionFruit.addEventListener("click", function(){
Ti.API.info("*************************** Clicked: " + sectionFruit.headerTitle);
});
var sectionVeg = Ti.UI.createTableViewSection({ headerTitle: 'Vegetables' });
sectionVeg.add(Ti.UI.createTableViewRow({ title: 'Carrots' }));
sectionVeg.add(Ti.UI.createTableViewRow({ title: 'Potatoes' }));
var sectionFish = Ti.UI.createTableViewSection({ headerTitle: 'Fish' });
sectionFish.add(Ti.UI.createTableViewRow({ title: 'Cod' }));
sectionFish.add(Ti.UI.createTableViewRow({ title: 'Haddock' }));
sectionFish.addEventListener("click", function(){
Ti.API.info("*************************** Clicked: " + sectionFish.headerTitle);
});
var table = Ti.UI.createTableView({
data: [sectionFruit, sectionVeg, sectionFish]
});
table.addEventListener("click", function(){
Ti.API.info("*************************** Clicked: table");
});
win.add(table);
win.open();
var currentRows = [];
var b1 = Ti.UI.createButton({
bottom: 10,
title: "remove Blue Row " + currentRows.length
});
b1.addEventListener("click", function(){
var r = currentRows.pop();
table.deleteRow(r);
if (currentRows.length >= 1) {
b1.title = "remove Blue Row " + (currentRows.length-1);
}
});
var b2 = Ti.UI.createButton({
bottom: 100,
title: "insert Blue Row after index 0"
});
b2.addEventListener("click", function(){
var r = Ti.UI.createTableViewRow({
height:80,
title:"Blue Row " + currentRows.length,
color:'blue'
});
table.insertRowAfter(0, r);
b1.title = "remove Blue Row " + currentRows.length;
currentRows.push(r);
r.addEventListener("click", function(){
Ti.API.info("*************************** Clicked: " + r.title);
});
});
var b3 = Ti.UI.createButton({
bottom: 190,
title: "append Blue Row"
});
b3.addEventListener("click", function(){
var r = Ti.UI.createTableViewRow({
height:80,
title:"Blue Row " + currentRows.length,
color:'blue'
});
table.appendRow(r);
b1.title = "remove Blue Row " + currentRows.length;
currentRows.push(r);
r.addEventListener("click", function(){
Ti.API.info("*************************** Clicked: " + r.title);
});
});
win.add(b1);
win.add(b2);
win.add(b3);
2. Click the buttons "append" or "insert" to add Blue Row to the table and then click the button "remove".
Expected:
The Blue Row is removed.
Actual:
The first row is removed.
Marking this as a new feature since iOS has never supported deleting row by row proxy. No idea how QE got the idea.
PR: https://github.com/appcelerator/titanium_mobile/pull/3388
Its working fine on iOS as well as android. Environment used for verification - Titanium SDK: 3.1.0.v20130305190758 Titanium Studio:3.0.2.201302141201 Device: iOS simulator 6.0 (and Samsung GALAXY Note Android 2.3.6)