Titanium Community Questions & Answer Archive

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

Tableview without a tabGroup = no rows! (bug)

If I create a tableview in a window that isn't assigned to a tabGroup, it no longer displays the rows in 1.4. Adding the window to the tabGroup causes the rows to show up again.

Sample code:
app.js
newWindow.js

When you run the app, you'll see the tableview header but not the row/text. If you uncomment the last lines in app.js, so that the new window is part of the tabGroup, the row/text will then show up.

Could someone else please confirm this? Any thoughts on a work-around that doesn't involve adding the new window to a tabGroup?

— asked July 31st 2010 by Mike Dosey
  • 1.4
  • bug
  • iphone
  • row
  • tabgroup
  • tableview
0 Comments

9 Answers

  • Yeah, it's doing this.

    Populate the table on the open event of the window the table belongs to, with setData.

    — answered July 31st 2010 by Dan Tamas
    permalink
    0 Comments
  • Thanks for the confirmation, Tamas. However, I tried adding the following code to the bottom of my newWindow.js, as you suggested, and it doesn't seem to make a difference:

    Ti.UI.currentWindow.addEventListener('open', function(e) {
       tableview.setData(data);
    });
    

    Is that what you had in mind?

    — answered July 31st 2010 by Mike Dosey
    permalink
    1 Comment
    • Does this actually work for you? I tried it with a very simple setup in Kitchen Sink and it's not working. I still see no rows in the table when using a grouped style.

      — commented October 27th 2010 by Christopher Bailey
  • Yeah, only that don't use Ti.UI.currentWindow, but a declared variable

    var the_win =  Tianium.UI.createWindow( the window that holds the table )
    
    the_win.addEvent('open', ....)
    

    Also use Titanium, not Ti, sometimes Ti it's lost in the scope of some functions( donno why )

    — answered July 31st 2010 by Dan Tamas
    permalink
    0 Comments
  • Hmmm…that still doesn't seem to change anything for me. Here's the updated app.js that I'm using (newWindow.js is empty now):
    app.js

    Not being able to use UI.currentWindow makes the code really awkward, because that forces me to define the event listener in the file that creates the window, rather than the file that creates the tableview. Regardless, I'd still like to see if I can get your idea to work.

    — answered July 31st 2010 by Mike Dosey
    permalink
    1 Comment
    • You can define the event listener in the tableview file also, just use

      var win = Titanium.UI.currentWindow;
      win.addEventListener('open', function(){
          //do your stuff
      }
      

      — commented July 31st 2010 by Goran Skledar
  • Does anyone else have any thoughts on a work-around for this?

    — answered August 4th 2010 by Mike Dosey
    permalink
    0 Comments
  • Bump..

    — answered August 5th 2010 by Mike Dosey
    permalink
    0 Comments
  • Just confirmed this behavior and filed a bug report in Lighthouse. Not sure why creating custom grouped view sections is not working in a standalone window. Possible near term solutions would be to use standard view components to achieve the same effect, or use standard table row attributes for the grouped view (which does work in a standalone window), as in:

    var data = [];
    
    var section = Ti.UI.createTableViewSection({
      headerTitle:'A section header'
    });
    
    data[0] = section;
    
    section.add(Ti.UI.createTableViewRow({hasChild:true,title:'Row 1'}));
    section.add(Ti.UI.createTableViewRow({hasDetail:true,title:'Row 2'}));
    section.add(Ti.UI.createTableViewRow({hasCheck:true,title:'Row 3'}));
    section.add(Ti.UI.createTableViewRow({title:'Row 4'}));
    
    // create table view
    var tableview = Titanium.UI.createTableView({
        data:data,
        style:Titanium.UI.iPhone.TableViewStyle.GROUPED,
    });
    
    // create table view event listener
    tableview.addEventListener('click', function(e)
    {
        // event data
        var index = e.index;
        var section = e.section;
        var row = e.row;
        var rowdata = e.rowData;
        Titanium.UI.createAlertDialog({title:'Table View',message:'row ' + row + ' index ' + index + ' section ' + section  + ' row data ' + rowdata}).show();
    });
    
    // add table view to the window
    Titanium.UI.currentWindow.add(tableview);
    
    — answered August 5th 2010 by Kevin Whinnery
    permalink
    0 Comments
  • On further investigation, from what I can tell, this isn't actually a problem with GROUPED table styles. It is when you use TableViewRow's (vs. just a generic object with a title/attributes) in the table. I can have a table that uses the GROUPED style, and has data such as [{title: "hello"}] and that works fine, but as soon as I create a row with createTableViewRow, add a field to it, and add it to the table, then it doesn't work.

    — answered October 28th 2010 by Christopher Bailey
    permalink
    0 Comments
  • This bug is really obnoxious in my case, as my entire app uses a grouped table view display for consistency, but I also need a login page that's not part of the tab group. I can't keep the look of my app consistent and I have to do all kinds of ridiculous shenanigans in the code to work around the problem. Kevin created this bug in Lighthouse months ago, but it's marked as low priority and isn't even being considered for 1.5. If anyone else is affected by this problem, please "watch" the bug in Lighthouse and add your comments there. Maybe someone will finally notice and decide to fix it.

    — answered December 11th 2010 by Mike Dosey
    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.