Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function setTableData() {
- var db = Ti.Database.install('mm.sqlite', 'recipes');
- var rows = db.execute('select i.caption, i_s.orderID, i_s.sectionID, i_s.name ' + 'from recipes r ' + 'inner join instructions i on r.fcid = i.recipeID ' + 'inner join inst_sections i_s on i.timeID = i_s.sectionID ' + 'where fcid IN (' + chosenRecipes + ') ' + 'order by i_s.orderID ASC');
- // create the array
- var dataArray = [];
- var tableData = [];
- while(rows.isValidRow()) {
- dataArray.push({
- title : '' + rows.fieldByName('caption') + '',
- section : '' + rows.fieldByName('name') + '',
- sortOrder : '' + rows.fieldByName('orderID') + '',
- hasChild : false
- });
- rows.next();
- };
- var pre = '';
- for(var i = 0, j = dataArray.length; i < j; i++) {
- if(dataArray[i].section != pre)
- tableData[i] = Ti.UI.createTableViewSection({
- headerTitle : dataArray[i].section
- })
- pre = dataArray[i];
- var tvr = Ti.UI.createTableViewRow();
- tvr.height = 'auto';
- var tvrl = Ti.UI.createLabel({
- text: dataArray[i].title,
- left: 10,
- top: 10,
- bottom: 10,
- right: 10,
- height: 'auto'
- });
- tvr.add(tvrl);
- tableData[i].add(tvr);
- }
- tv.data = tableData;
- }
Add Comment
Please, Sign In to add comment