Titanium JIRA Archive
Appcelerator Community (AC)

[AC-1397] iOS: Rendering issue when deleting and re-adding row

GitHub Issuen/a
TypeBug
Priorityn/a
StatusResolved
ResolutionDuplicate
Resolution Date2014-06-16T21:36:10.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsn/a
ReporterIvan Skugor
AssigneeShuo Liang
Created2014-06-03T10:07:27.000+0000
Updated2016-03-08T07:37:49.000+0000

Description

There's one issue when row is being deleted and then re added. To see this issue, run this code:
Ti.UI.setBackgroundColor("#fff")

var win = Ti.UI.createWindow({
	top: 20,
	backgroundColor: "#ccc"
});

var table = Ti.UI.createTableView({
	top: 0,
	bottom: 0
});

var section = Ti.UI.createTableViewSection({
	headerView: Ti.UI.createLabel({ text: "Section" })
});

for (var i = 0; i < 10; i++) {
	section.add(Ti.UI.createTableViewRow({
		title: "Row " + (i + 1)
	}));
}

table.setData([ section ]);

var newSection;
table.addEventListener("click", function(e) {

	var row = table.data[0].rows[e.index];

	Ti.API.info('index');
	Ti.API.info(e.index);
	Ti.API.info(row.title);

	table.deleteRow(row);
	table.insertRowBefore(0, row);
	/*setTimeout(function() {
		table.insertRowBefore(0, row);
	}, 3000);*/

});

win.add(table);

win.open();
Basically, this code moves clicked row to first position in table. So, for example, you can click on "Row 2" and it should move before "Row 1". The problem is that's not what happens. For some reason, there are two "Row 2". You can click again on second row, and everything resets. Check the logs, seems to be okay there, just the rendering in not correct. If timeout is introduced for row re addign (like in commented part), everything will work fine.

Comments

  1. Shuo Liang 2014-06-09

    Hi, This is a refresh issue. After you delete a row, the page still not refresh, so second action "insertRow" will not work well. I will talk to our engineer team to figure it out whether is it a bug, and keep you up to date. For now, if you really need it shortly´╝î you can add one more action between "delete" action and "insert" action, like do a timeout or Ti.API.info(); Regards, Shuo
  2. Ivan Skugor 2014-06-09

    I did a timeout, I said that, there's commented part with "setTimeout". I don't understand how can this not be a bug, it's not a feature for sure :D
  3. Shuo Liang 2014-06-10

    Filed a ticket to engineer team already.
  4. Ivan Skugor 2014-06-10

    Great, thank you.
  5. Radamantis Torres-Lechuga 2014-06-16

JSON Source