Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-6858] Android: deleterow method always delete the first row

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-01-23T16:16:44.000+0000
Affected Version/sRelease 1.8.0.1
Fix Version/sSprint 2012-01, Release 2.0.0, Release 1.8.1
ComponentsAndroid
Labelsmodule_tableviewrow, qe-testadded, regression
ReporterKarol Pomaski
AssigneeBill Dawson
Created2011-12-23T10:11:52.000+0000
Updated2012-02-10T00:11:15.000+0000

Description

Problem

While using deleterow() method in TableView it always delete the first row (does not matter what index number we put).

Regression - works fine with SDK 1.7.5

Reproducible Steps

1. Run the above code 2. Press last row named "goodgirl"

Sample Code

var win = Ti.UI.createWindow({
    title : 'xmas'
});

var table = Ti.UI.createTableView({
    title : 'just a test'
});

win.add(table);
win.open();

var data = ['goodday', 'goodtime', 'goodboy', 'goodgirl'];
var arr = [];

for(var i = 0, max = data.length; i < max; i++) {

    arr[i] = Ti.UI.createTableViewRow({
        title : data[i],
        name : data[i]
    });
}

table.setData(arr);
table.allrows = arr;


for(var j = 0, len = table.allrows.length; j < len; j++) {
    table.allrows[j].addEventListener('click', function(e) {
        var index = table.getIndexByName(e.rowData.name);
        Ti.API.info(index);
        //alert(table.data[0].rowCount);
        table.deleteRow(index);
    });
}

Comments

  1. Mark Ruys 2011-12-27

    The problem is also reproducable in the KitchenSink table_view_row_delete.js. It should delete the last row, but deletes the first. Note that tableview.data.length gives 1 instead of 5. This seems another 1.8.0.1 bug to me. Is it counting sections instead of rows?
  2. Marco Schierhorn 2011-12-28

    Yep, i can confirm that. Same here. Seems to count the sections
  3. Sumit Kataria 2012-01-02

    I confirm this too.
  4. Bill Dawson 2012-01-03

    Pull request ready https://github.com/appcelerator/titanium_mobile/pull/1115
  5. Wilson Luu 2012-01-12

    Closing bug. Verified fix on: SDK build: 1.9.0.v20120111233134 Runtime: V8, Rhino Titanium Studio, build: 1.0.8.201201111843 Device: Droid 3 (2.3.4)
  6. Peter Bosch 2012-01-30

    Seems to me this works for Android 2.3.3 but not for Android 2.2

JSON Source