Skip to content

Instantly share code, notes, and snippets.

@minhnc
Created February 14, 2012 09:14
Show Gist options
  • Save minhnc/1825026 to your computer and use it in GitHub Desktop.
Save minhnc/1825026 to your computer and use it in GitHub Desktop.
win2.js
var win = Ti.UI.currentWindow;
function doDbThing() {
var db = Titanium.Database.open('doctor_names');
var data = [];
var rows = db.execute('SELECT * FROM doctor ORDER BY name');
while(rows.isValidRow()) {
var custom_row = Ti.UI.createTableViewRow();
var label = Ti.UI.createLabel({
text : rows.fieldByName('name'),
font : {
fontWeight : 'bold',
fontSize : 14
},
left : 60,
color : 'white',
borderRadius : 8,
backgroundGradient : {
type : 'linear',
colors : ['#101010', '#555555'],
startPoint : {
x : 0,
y : 0
},
endPoint : {
x : 2,
y : 60
},
backFillStart : false
},
height : 30,
width : 150
});
custom_row.add(label);
data.push(custom_row);
rows.next();
}
rows.close();
var tableView = Titanium.UI.createTableView({
data : data,
height : 250,
top : 45,
backgroundColor : '#454545',
allowsSelection : false
})
//tableView.footerView = Ti.UI.createView({width: 0, height: 0});
db.close('doctor_names');
win.add(tableView);
}
Titanium.App.addEventListener('app:clicked', function() {
alert('clicked');
doDbThing();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment