Created
November 14, 2012 18:51
-
-
Save QGao/4073972 to your computer and use it in GitHub Desktop.
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 characters
var lineItemsSection = Ti.UI.createTableViewSection({ | |
headerView : lineItemsHeaderView | |
}); | |
var rows = []; | |
for(var i = 0; i < itemCount; i++) { | |
var tableViewRow = Ti.UI.createTableViewRow({ | |
id : "lineItemDetails", | |
data : data[i], | |
hasChild : true, | |
selectionStyle : Titanium.UI.iPhone.TableViewCellSelectionStyle.GRAY | |
}); | |
var rowContainer = Ti.UI.createView({ | |
touchEnabled : false, | |
index : i, | |
height : 40 | |
}); | |
var lblDescription = Ti.UI.createLabel({ | |
text : data[i].DESCRIPTION, | |
font : tvStyles.propertyValueFont, | |
color : Colors.LightGrey, | |
left : 10, | |
touchEnabled : false | |
}); | |
rowContainer.add(lblDescription); | |
tableViewRow.add(rowContainer); | |
rows.push(tableViewRow); | |
if(i < 1) { | |
lineItemsSection.add(tableViewRow); | |
} | |
}; | |
var processing = false; | |
lineItemsHeaderView.addEventListener("click", function(e) { | |
if(!processing){ | |
processing = true; | |
if(itemCount > 1) { | |
e.source.expanded = !e.source.expanded; | |
if(e.source.expanded) { | |
Ti.API.info('expended'); | |
imgHasChild.backgroundImage = "/assets/downArrow.png"; | |
for(var i = 1; i < itemCount; i++) { | |
lineItemsSection.add(rows[i]); | |
} | |
lineItemsSection.height = itemCount * 40; | |
} else { | |
Ti.API.info('not expended'); | |
imgHasChild.backgroundImage = "/assets/cartArrow.png"; | |
for(var i = 1; i < itemCount; i++) { | |
lineItemsSection.remove(rows[i]); | |
} | |
lineItemsSection.height = 80; | |
} | |
} | |
self.resetData(lineItemsSection); | |
processing = false; | |
} | |
}); | |
return lineItemsSection; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment