-1

I'm trying to create an app using Titanium Studio that will display information from an SQLite database. To make things simpler, lets say my database have the following columns: Last Name, Given Name, Age, Race & Religion

I currently have a basic framework for the app, which consists of multiple tabs. In one of the tabs (which corresponds to a particular window), I would like to have a TableView that displays only Last Name, Given Name & Age in each row.

How do I do that? Appreciate all the help I can get!

Thanks!

4

1 回答 1

0

Have you looked at this?

So once you get the rows from the database, just create rows for your tableview. Here is a start:

// Fetch the db and execute a select from your person table
var db = Ti.Database.open('mydb');
var rows = db.execute('SELECT * FROM person');

var persons = [];
while (rows.isValidRow())
{
    persons.push({title : + rows.fieldByName('Last Name'));
    rows.next();
};
rows.close();

var yourTable = Ti.UI.createTableView({
    width : Ti.UI.FILL,
    height : Ti.UI.FILL,
    data: persons // Set the rows to the table
});

// Dont forget to close the db
db.close();

Use this as a reference to style your table rows more effectively.

于 2013-01-26T01:24:24.317 回答