Created
January 19, 2012 01:19
-
-
Save egomez99/1636986 to your computer and use it in GitHub Desktop.
Resetting table with setData
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
Ti.UI.setBackgroundColor('#000'); | |
var openButton = Ti.UI.createButton({ | |
title : 'Open Win' | |
}); | |
var win = Ti.UI.createWindow({ | |
title : 'Root Win', | |
tabBarHidden : true, | |
rightNavButton : openButton | |
}); | |
var tab = Ti.UI.createTab({ | |
title : 'Root Tab', | |
window : win | |
}); | |
var grp = Ti.UI.createTabGroup({ | |
tabs : [tab], | |
zIndex : 0 | |
}); | |
grp.open(); | |
win.open(); | |
var testWin = Ti.UI.createWindow(); | |
var table = Ti.UI.createTableView(); | |
testWin.add(table); | |
var open = function() { | |
reset(); | |
build(); | |
tab.open(testWin, { | |
animated : true | |
}); | |
}; | |
var reset = function() { | |
table.setData = []; | |
}; | |
var build = function() { | |
addHead(); | |
addRow(); | |
}; | |
var addHead = function() { | |
var row = Ti.UI.createTableViewRow({ | |
height : 600, | |
backgroundColor : 'red', | |
selectionStyle : 'none' | |
}); | |
table.appendRow(row); | |
table.setContentInsets({ | |
top : -600 | |
}); | |
}; | |
var addRow = function() { | |
var label = Ti.UI.createLabel({ | |
text : 'I am a row', | |
width : 'auto', | |
height : 'auto' | |
}); | |
var row = Ti.UI.createTableViewRow({ | |
backgroundColor : 'yellow' | |
}); | |
row.add(label); | |
table.appendRow(row); | |
}; | |
openButton.addEventListener('click', open); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment