Skip to content

Instantly share code, notes, and snippets.

@egomez99
Created January 19, 2012 01:19
Show Gist options
  • Save egomez99/1636986 to your computer and use it in GitHub Desktop.
Save egomez99/1636986 to your computer and use it in GitHub Desktop.
Resetting table with setData
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