Disable Delete icon in TableView edit mode?
I'm constructing a TableView with custom rows. I want the users to be able to switch to the Edit mode, which they can select multiple items, then hit "Complete" to mark these items as completed.
The problem is as soon as I set
tableView.editing = true
the red (-) would appear, but I don't want the user to remove the rows. But there seems to be nowhere in the API to disable this default behavior.
My alternative approach is to re-render the row when user clicks on the "Edit" button and customize the row accordingly.
So my question is whether it's possible to turn off the Delete icon in the edit mode.
4 Answers
-
Check here: http://developer.appcelerator.com/question/54461/exclude-rows-from-editablemoving
-
Glad to see others are having my same issue (I'm the one that asked & answered the question Ben referred to)……this really should be documented.
To prevent deleting a row: set editable = false for the row.
-
Thanks for answering my question. I should have been a bit clearer in the original question. I actually want to have the editing animation to occur when you set the editing=true property of the tableView (the right-shifting animation for the rows which the hasChild icons disappearing and the red icons appearing). But in my case, I don't want to have the red icon to appear. However, Setting editable=false for the row means that it won't go into the edit mode at all, so no animation would occur.
If you have RememberTheMilk app, click the "Edit" button in the tasks list will switch to the selection mode which you can select the tasks then hit the "Complete" button to complete them. This is what I wanted to mimic. If the red delete button can somehow be removed, then it's pretty simple to do something like that in Titanium.
I tried to hack it around by looping thru my custom rows, and for each row, applied a translation transition to every child elements to mimic the shifting. The result wasn't too good because the animation was chugging and stopped at various random unfinished states. I also tried to apply the shifting transform to the row but the row itself doesn't seem to animate at all. Then I applied the transition transform to the tableView, but now the entire screen got shifted. So basically I just gave up on the animation, and just used a quick image toggle instead.
-
Just wondering if anyone ever figured this out? I also would like to use the edit mode to select multiple rows and then run a function based on those selected rows. But I can't seem to figure out if its possible.