Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-15932

iOS: Editable TableView loses correct index when using swipe-delete gesture then .deleteRow()



      The following tableview displays 20 numbered rows. The tableview is set as "editable:true", so the swipe-to-delete gesture is enabled in iOS. The tableview also has a click event handler, so any row clicked on, will be deleted as well with the TableView.deleteRow() method. The idea is that a user can swipe-to-delete any row, or simply click any row to delete it.

      Problem: Swipe-deleting a row, then calling .deleteRow() on a later row causes the display to remove the incorrect row. Seems like Swipe-to-delete is causing an indexing problem with the rows.

      For example;

      1. Load the app.

      2. Click on "Row 1" to delete it. This works fine.

      3. Swipe-to-delete "Row 2" and delete it. This works fine.

      3. Click on "Row 3" to delete it. This fails, and "Row 4" gets deleted instead of "Row 3".

      Anytime you swipe-delete a row, any other rows below that one which are deleted with TableView.deleteRow() miss the correct index, instead deleting something farther below their index.

      The more swipe-deletes you do, the more the index is offset incorrectly when calling .deleteRow().

      Using $.tv.deleteRow(e.index) or $.tv.deleteRow(e.row) does not make a difference.

      Here's the code:


            <TableView id="tv" editable="true" onClick="tv_onClick">	


      var tableData = [];
      for (var i=1; i<21; i++) {
        tableData.push({ title: 'Row ' + i });
      function tv_onClick(e) {	




            • Assignee:
              srahim Sabil Rahim
              ewieber Eric Wieber (Inactive)
            • Watchers:
              0 Start watching this issue


              • Created:

                Backbone Issue Sync

                • Titanium SDK/CLI <> Titanium Mobile
                  Synced with:
                  Sync status:
                  Last received:
                  Last sent:

                  Git Integration