Skip to content

Instantly share code, notes, and snippets.

@iskugor
Created May 23, 2012 13:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iskugor/2775243 to your computer and use it in GitHub Desktop.
Save iskugor/2775243 to your computer and use it in GitHub Desktop.
Titanium: How to append table view section to rendered table view
(function() {
var win = Ti.UI.createWindow({ backgroundColor: "#f00" });
var table = Ti.UI.createTableView();
var rows = [];
for (var i = 0; i < 4; ++i) {
rows.push({ title: "Row 0", header: "Header " + i, className: "Row1" });
for (var j = 0; j < 10; j++) {
rows.push({ title: "Row " + j, className: "Row2" });
}
}
table.setData(rows);
win.add(table);
function appendSection(tableView, sectionTitle) {
var sections = tableView.data;
sections.push(Ti.UI.createTableViewSection({ headerTitle: sectionTitle }));
tableView.setData(sections);
}
win.addEventListener("open", function() {
appendSection(table, "Title");
});
win.open();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment