TableView issue with className - Wrong row(s) updated!

You must Login before you can answer or comment on any questions.

Greetings,

I have created a TableView, added a handful of rows then update one of those rows. The problem is that the wrong row or rows are being updated. If I turn the phone on the side and then back again, the rows show the correct information. I found that if I do not add "className" then it works fine. However I am under the impression that "className" is utilized internally to improve performance.

We are also having problems with wrong check boxes on rows being updated. I wonder if this is related.

The following code reproduces the issue. I have simplified everything, removing all of the complexities of my actual application.

Titanium.UI.setBackgroundColor('#000');
 
var win1 = Titanium.UI.createWindow({title:'Window 1'});
var TheListBox=Ti.UI.createTableView();
win1.add(TheListBox);
 
win1.addEventListener('open',OnLoad);
function OnLoad()
{
  function AddRow(_Caption)
  {
    _Caption = String(_Caption);
 
    // This works!
//    var RowObj=Ti.UI.createTableViewRow({title:_Caption});
 
    // This causes the wrong row or rows to be updated!                                          
    var RowObj=Ti.UI.createTableViewRow({className:'Anything here causes the problem!', title:_Caption});
 
    RowObj.Label=Ti.UI.createLabel({text:_Caption});
    RowObj.add(RowObj.Label);
    TheListBox.appendRow(RowObj);
  }
 
  for (i=1;i<=10;i++)
    AddRow(i);
}
 
  function OnTimeout()
  {
    TheListBox.data[0].rows[5].Label.text = 'OnTimeout';
  }
var TheTimer = setInterval(OnTimeout, 2000);
 
win1.open();
In the above example, the row labeled '6' should show 'OnTimeout', all the reset should show 1-9. The 6th row does show 'OnTimeout' correctly however, the 8th row also shows 'OnTimeout', which is incorrect.

Turn the phone on the side and the rows will magically be displayed correctly!

Change the code as follow and it works fine...

Titanium.UI.setBackgroundColor('#000');
 
var win1 = Titanium.UI.createWindow({title:'Window 1'});
var TheListBox=Ti.UI.createTableView();
win1.add(TheListBox);
 
win1.addEventListener('open',OnLoad);
function OnLoad()
{
  function AddRow(_Caption)
  {
    _Caption = String(_Caption);
 
    // This works!
    var RowObj=Ti.UI.createTableViewRow({title:_Caption});
 
    // This causes the wrong row or rows to be updated!                                          
//    var RowObj=Ti.UI.createTableViewRow({className:'Anything here causes the problem!', title:_Caption});
 
    RowObj.Label=Ti.UI.createLabel({text:_Caption});
    RowObj.add(RowObj.Label);
    TheListBox.appendRow(RowObj);
  }
 
  for (i=1;i<=10;i++)
    AddRow(i);
}
 
  function OnTimeout()
  {
    TheListBox.data[0].rows[5].Label.text = 'OnTimeout';
  }
var TheTimer = setInterval(OnTimeout, 2000);
 
win1.open();
The only difference is that "className" is not set!

— asked 2 years ago by Pete Berry
2 Comments
  • I have seen the same problem. It's got to be some kind of pointer bug in Titanium.


    Titanium Studio 1.0.4.201108101535

    Mobile SDK 1.8.0.v20110913141920

    Android 2.2

    — commented 2 years ago by Shawn Lipscomb

  • This problem is present in SDK 2.1.0 as well. Must be a bug.

    — commented 1 year ago by Alex Raz

Your Answer

Think you can help? Login to answer this question!