I am creating a TableView, then looping over a DB recordset, adding 1 TableViewRow at a time to the table. But something is not working right. The table ends up on the window because I can see the row line separators, but the labels/text and switches do not appear.
Here is my table definition:
var genres = Ti.UI.createTableView({
top: 0,
height: '75%',
backgroundColor: '#000000',
backgroundFocusedColor: '#9DF5B7'
});
[ENTER LOOP]
var genreRow = Titanium.UI.createTableViewRow({
height: 'auto'
});
var genreText = rsGenres.fieldByName('Genre');
var genreLabel = Ti.UI.createLabel({
color: '#ffffff',
//text: genreText,
text: 'foobar',
textAlign: Ti.UI.TEXT_ALIGNMENT_LEFT,
width: Ti.UI.SIZE, height: Ti.UI.SIZE
});
Ti.API.info("Genre: " + rsGenres.fieldByName('Genre'));
var genreSwitch = Ti.UI.createSwitch({
titleOn: 'On',
titleOff: 'Off',
right: 5,
value: true // mandatory property for iOS
});
genreRow.add(genreLabel);
genreRow.add(genreSwitch);
genres.add(genreRow);
[EXIT LOOP]
win4.add(genres);
You can see that I commented out the genreText binding in genreLabel and replaced it with hardcoded "foobar" text, but even that does not appear. You can also see my Ti.API.Info() line, and in the console I can see all my genres, the data is there, and the loop is working.
Why can't I see the label text nor the switch controls on my table?
either append row in table view while iterating the loop
table.appendRow(row);
or
add table view rows in some array like
var data= [];
// loop start
data.add(row);
// loop end
table.setData(data);