Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

createTableViewRow... why does this not work?

What am I missing here?
I only get an empty table with no text.

var win1 = Ti.UI.createWindow({
     backgroundColor:"#fff",
     title:"Test"
});

var table1 = Ti.UI.createTableView({});
var row1 = Ti.UI.createTableViewRow({title:'Hello'});
table1.add(row1);
win1.add(table1);

win1.open();

edit: Updated code

— asked December 6th 2010 by g wz
0 Comments

3 Answers

  • Accepted Answer

    should be appendRow

    table1.appendRow(row1);
    
    — answered December 6th 2010 by Aaron Saunders
    permalink
    0 Comments
  • Do you have something like this in your code? Otherwise when you use "win1.add(table1);" you won't be adding it to anything.

    var win1 = Titanium.UI.currentWindow;
    

    Cheers

    John

    — answered December 6th 2010 by John Howell
    permalink
    2 Comments
    • I'm just taking the base app.js that gets created when you start a new project. 'win1' is already being defined with:
      var win1 = Titanium.UI.createWindow({ …

      Plus, the table IS being displayed, however, it is empty. The "Hello" text does not appear.

      — commented December 6th 2010 by g wz
    • I've updated the code in the original post.

      — commented December 6th 2010 by g wz
  • another way to add rows, which is used through out the kitchen sink examples is to create an array of rows and then just set the table data to that array

    var dataArray = [
        Ti.UI.createTableViewRow({title:'Hello One'}),
        Ti.UI.createTableViewRow({title:'Hello Two'})
    ];
    var table1 = Ti.UI.createTableView({data: dataArray});
    win1.add(table1);
    
    — answered December 6th 2010 by Aaron Saunders
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.