[AC-1993] iOS: appendRow to a TableViewSection doesn't work
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | n/a |
| Status | Closed |
| Resolution | Duplicate |
| Resolution Date | 2013-08-05T21:40:51.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | n/a |
| Components | n/a |
| Labels | appendrow, tableviewrow, tableviewsection |
| Reporter | Matej |
| Assignee | Mauro Parra-Miranda |
| Created | 2013-08-05T19:45:01.000+0000 |
| Updated | 2016-06-21T11:12:09.000+0000 |
Description
AppendRow/InsertRow... to a TableViewSection absolutely doesn't work! Tested it anyone before publication in the Ti Docs?
var win = Ti.UI.createWindow({
backgroundColor: "white"
});
var table = Ti.UI.createTableView({
width: Ti.UI.FILL, height: Ti.UI.FILL,
style: Ti.UI.iPhone.TableViewStyle.GROUPED
});
var section_1 = Ti.UI.createTableViewSection();
var section_2 = Ti.UI.createTableViewSection();
section_1.add(Ti.UI.createTableViewRow({title: "ROW_1"}));
section_1.add(Ti.UI.createTableViewRow({title: "ROW_2"}));
section_1.add(Ti.UI.createTableViewRow({title: "ROW_3"}));
var addNextRow = Ti.UI.createTableViewRow({title: "Add next row"});
addNextRow.addEventListener("click", function(){
section_2.appendRow(Ti.UI.createTableViewRow({title: "Added row..."}));
});
section_2.add(addNextRow);
table.data = [section_1, section_2];
win.add(table);
win.open();
As explained in TIDOC-622, you must use setData to create a new section layout. Workaround here: https://gist.github.com/iskugor/2775243 The appendRow method is available for the TableView class, not the TableViewSection class. See: http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.UI.TableView-method-appendRow
Next workaround...nice https://gist.github.com/iskugor/2775243 -> This is about how to appendSection to a tableView not how to appendRow to a section. Why is in the Ti Docs this: ??Before the table is rendered, the TableViewSection add method may be used to add TableViewRow objects to a section. After it is rendered, one of the TableView insertRowBefore, insertRowAfter, or appendRow methods must be used instead.?? -> How to appendRow to a section using functions above...?
yep, I agree with the above comment