Titanium Community Questions & Answer Archive

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

(Android) Tableview: updateRow with headers

Hi,

I'm not sure if this is a known bug, but: when I try to update a row of a table view using the code below I get an out of bounds error, but its fine if I take the headers out of the table. Is this my error or a bug?

Cheers,
Mark.

var LogFind = Ti.UI.createTableView({
    data: [
            { header: 'Details', title: 'Tag', hasChild: true, color: 'black', url: 'LogFind/LogFind.js' }, 
            { title: 'Comment', hasChild:true, color: 'black', url: 'LogFind/LogFind.js' }, 
            { header: 'Images', title: 'Picture 1', hasChild:true, color: 'black', url: 'LogFind/LogFind.js' }, 
            { title: 'Picture 2', hasChild: true, color: 'black', url: 'LogFind/LogFind.js' }, 
            { title: 'Picture 3', hasChild: true, color: 'black', url: 'LogFind/LogFind.js' }, 
            { header: 'Commands', title: 'GPS', color: 'black', url: 'LogFind/LogFind.js' },
            { title: 'Submit', hasChild: true, color: 'black', url: 'LogFind/LogFind.js' }
        ]
})

LogFind.addEventListener ('click', function(e) {
    alert((e.index))
})

var win = Titanium.UI.createWindow ({
    backgroundColor: Globals.backgroundColor    
});

win.add(LogFind);
win.open();

LogFind.updateRow(5, { title: 'Getting GPS...' });
— asked March 31st 2010 by Mark Peace
  • android
  • header
  • tableview
  • updaterow
0 Comments

14 Answers

  • Yeah, weak sauce guys… Let's fix this…

    — answered September 28th 2011 by Dan Frist
    permalink
    1 Comment
    • FYI for anyone who is having this issue, I did it this way.

      if(isAndroid) {
          table.data[0].rows[INDEX_OF_ROW].label.text = TEXT;
      } else {
          table.updateRow(INDEX_OF_ROW, create_row(TEXT), {
              animated : true
          });
      }
      

      — commented September 28th 2011 by Dan Frist
  • i'm not exactly sure, but isn't the row index based on zero?

    — answered March 31st 2010 by Christian Sigl
    permalink
    0 Comments
  • Hiya,

    Still got the problem - even when using 'name' and 'getIndexByName'. The getIndex is returning the appropriate index, but then the updateRow fails if the headers are there.

    Mark.

    — answered April 1st 2010 by Mark Peace
    permalink
    0 Comments
  • I've opened Ticket 697 for this issue. You should set a watch on the ticket to receive updates.

    — answered April 1st 2010 by Don Thorp
    permalink
    1 Comment
    • Any resolution to this issue yet? This is a bit of a show stopper to the app I'm developing…

      — commented July 13th 2010 by Matt Newbill
  • Wow, Ticket 697 is still an open bug. I'm having a problem with updates and tableview and wonder how stable this is. Cost me more than 2 days so far. Any updates on this?

    — answered September 14th 2010 by Curtis Olson
    permalink
    0 Comments
  • Does anyone know of a workaround for this? I'm having the same problem and it looks like ticket 697 is still open.

    — answered December 28th 2010 by John Williams
    permalink
    0 Comments
  • The bug still persists! =(

    — answered March 11th 2011 by Thiago Oliveira
    permalink
    0 Comments
  • So, the bug is still there… any workaround?

    — answered May 9th 2011 by Leonardo Prunk
    permalink
    0 Comments
  • When A YEAR passed by and nothing got done.

    The bug is still there…..

    Oh god, I don't ask for more features, but only bugs get fixed… please.

    — answered September 19th 2011 by Neti Pengkhuan
    permalink
    0 Comments
  • Don't know about android, but I've had troubles with accessing rows in the table on iphone when having headers. The problem is in data[0].row[row_index] when you have headers you nead to do something like data[group_index].row[row_index_within_that_group]

    — answered October 2nd 2011 by Zhenya Kogan
    permalink
    0 Comments
  • 25

    — answered June 19th 2012 by Bill Freedman
    permalink
    0 Comments
  • very easy, the position isn't exists, you should use without header…

    — answered October 17th 2013 by eden ariel guzman andia
    permalink
    0 Comments
  • The use of a header attribute when creating a row is syntactic sugar for creating a section then adding rows to that section. Once the TableView is created from this declarative style, the rows are available programmatically as:

    table.sections[i].rows[j]  
    

    The 3 header attrs in the OP data will create 3 sections. Each additional row is appended to the previous section until a new header attr is encountered.

    I'm not sure if this bug is closed or not, the link is inaccessible. There's a lot of confusion in these answers and I think it largely stems from this understanding. Incidentally, the Titanium.UI.ListView contains it's runtime data in a similar way: list.sections[i].items[j]

    — answered November 20th 2013 by Roland Hordos
    permalink
    0 Comments
  • Well, the problem is with the index you're passing to updateRow, but I can't figure out why it's a problem.

    It's interesting that it works when you remove the headers. There seems to be a variety of issues relating to headers at the moment.

    You should be able to get around it by adding a name to the row:

    { name:'gps', header: 'Commands', title: 'GPS', color: 'black', url: 'LogFind/LogFind.js' }
    

    Then call:

    LogFind.updateRow(LogFind.getIndexByName('gps'), { title: 'Getting GPS...' });
    
    — answered March 31st 2010 by James K
    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.