I've got a table view with an edit function on, and I can drag my rows up and down and change their position.
This works fine and I have a little SQL function which update the position ID of the row that moves.
The problem I'm having is that it won't update the other rows at the same time. How do I do this?
For example, we start with this.....
Position 1: Row1 Position 2: Row2 Position 3: Row3 Position 4: Row4
You move Row4 to Position 2 and it updates using my script below to the correct one. The issue is Row2 then drops to Position 3 and Row3 drops to position 4, but they obviously don't change their position_id.
Here is my code on the 'move' listener
tableView.addEventListener('move', function(e) {
var newRow = e.row.row + 1;
Ti.API.info(e.rowData.speciesID + ' ' + e.rowData.speciesName + ' moved to position ' + newRow);
// update the order number
var db3 = Ti.Database.open('myDB');
db3.execute('UPDATE tour SET position_id=? WHERE tourItemID=?',newRow,e.rowData.speciesID);
db3.close(); });
Any suggestions on what i can do to update all the rows to the correct 'position_id'?
Running latest Titanium on iOS 8.2
Simon
Aucun commentaire:
Enregistrer un commentaire