Skip to content

Instantly share code, notes, and snippets.

@egomez99
Created January 25, 2012 23:22
Show Gist options
  • Save egomez99/1679623 to your computer and use it in GitHub Desktop.
Save egomez99/1679623 to your computer and use it in GitHub Desktop.
Wipe clean tableView
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
});
};
testWin.addEventListener('close',function(){
reset();
});
var reset = function() {
table.setData([]);
Ti.API.info('Table wiped clean');
};
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