Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-9267] iOS: tableView - row not always getting removed with deleteRow

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionCannot Reproduce
Resolution Date2017-05-24T21:39:29.000+0000
Affected Version/sRelease 2.1.0, Release 2.0.1, Release 3.1.0
Fix Version/sn/a
ComponentsiOS
Labelsapi
ReporterJon Alter
AssigneeEric Merriman
Created2012-05-24T16:16:32.000+0000
Updated2017-05-24T21:39:29.000+0000

Description

TableView rows are not always getting deleted with deleteRow

Steps to reproduce:

Step 1. run the code below Step 2. click on either of the "Parent" rows several times until only one of the children remains but not both or there are 3 Children under one Parent. This happens occasionally, not every time. (attaching a screenshot).
var win  = Ti.UI.createWindow({
	backgroundColor: 'green'
});
win.open();

var container = Ti.UI.createView({backgroundColor: "white", layout: "vertical"});

var layout = [

	{
		title: "Parent 1",
		isparent: true,
		opened: false,
		sub: [
			{
				title: "Child 1"
			},
			{
				title: "Child 2"
			}
		]
	},
	{
		title: "Parent 2",
		isparent: true,
		opened: false,
		sub: [
			{
				title: "Child 3"
			},
			{
				title: "Child 4"
			}
		]
	}

];
var tableView = Ti.UI.createTableView({
	// style:Titanium.UI.iPhone.TableViewStyle.GROUPED,
	top: 0,
	height: Ti.Platform.displayCaps.platformHeight,
	data: layout
});


tableView.addEventListener("click", function(e) {

	//Is this a parent cell?
	if(e.row.isparent) {

		//Is it opened?
		if(e.row.opened) {
			for(var i=e.row.sub.length; i > 0; i = i - 1) {
				tableView.deleteRow(e.index + i);
			}
			e.row.opened = false;
		}

		else {
			//Add teh children.
			var currentIndex = e.index;
			for(var i=0; i < e.row.sub.length; i++) {
				tableView.insertRowAfter(currentIndex, e.row.sub[i]);
				currentIndex++;
			}
			e.row.opened = true;
		}

	}

});

container.add(tableView);
win.add(container);

Attachments

FileDateSize
Screen Shot 2012-05-24 at 4.15.15 PM.png2012-05-24T16:16:32.000+000012508

Comments

  1. Shameer Jan 2013-04-12

    Issue reproduces Tested with Titanium Studio, build: 3.0.1.201212181159 Titanium SDK version: 3.1.0 Titanium SDK version: 3.0.2 iOS iPhone Simulator: iOS SDK version: 6.
  2. Lee Morris 2017-05-24

    Closing this ticket as the issue cannot be reproduced with the following environment; iPhone 7 (10.2) MacOS 10.11.6 (15G31) Studio 4.9.0.201705021158 Ti SDK 6.1.0.v20170519131839 Appc NPM 4.2.9 Appc CLI 6.2.1 Ti CLI 5.0.13 Alloy 1.9.11 Arrow 2.0.0 Xcode 8.2 (8C38) Node v4.8.2 Java 1.7.0_80

JSON Source