Hello all,
I’ve been experimenting with the tableview:deleteRows function and it’s very cool how smooth and easy this call is to delete multiple rows! However, some weird parts about this:
It makes sense in a way that the indices don’t automatically update to “fill in”. For example if I delete 2,3,4 out of 1,2,3,4,5,6.
But I’m having trouble updating these indices manually to be sequential again:
1,2,3,4,5,6 Delete 2,3,4 - > 1,5,6 == But I want to be able to delete in order, so ==> 1,2,3
If we just leave it like this, we aren’t able to complete the delete call for multiple sequential elements (three in a row) after we’ve already deleted rows that were in between.
So the fix is to use tableView:deleteAllRows(), then add all existing rows back in to a “refreshed” table to get sequential indices. This is great, and we’ve already got solutions like this for our previous tableviews that can receive deletes.
The problem lies in that deleteRows is an animation without an onComplete listener, so we have to guess when the animation will be done (slideLeftTransitionTIme + slideUpTransitionTime + small overhead in milliseconds) to reload the table so that we get both the animation and the sequential indices.
So my problems are:
Non-sequential indices after deleteRows
Inability to use event-driven table reloads, having to rely on timers that aren’t completely accurate
And my questions are:
Am I doing this wrong? Is there a more sane way to do this?
And is there any possibility that this Corona API call is still young and needs additional parameters such as an onComplete listener, or some flags that could “fill in” table indices?
I’ll be doing tests to see if I can manually assign row indices to rows instead of having to delete everything and add it back in, and if that works, great.
Thanks for your help everyone! I look forward to your responses!