-
-
Save chmiiller/54f89e0964dc2a50d87d40e01f6089e6 to your computer and use it in GitHub Desktop.
Revisions
-
rileydutton revised this gist
Apr 28, 2011 . 1 changed file with 54 additions and 55 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,69 +1,68 @@ 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); -
rileydutton created this gist
Apr 28, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,69 @@ 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);