Changing all rows in a tableview
I am trying to change the layout of all rows in a tableview at the same time. Is there a way to do that?
This is what I want to do:
http://4.bp.blogspot.com/_QLwms0mVa4w/SQN0MqPIpXI/AAAAAAAAAA8/lEikKn9eP_0/s320/Screenshot+2008-10-25+15:31:21+-0400-1.png
Here's what I want to do in detail. I'm attempting to build an edit mode for a tableview which will be toggled by a button. When the edit mode is on, I can select multiple rows (blog articles, in fact) and apply a certain action to them (delete/move/edit settings).
I could do the select UI by adding hascheck to each row on click, however I would really like to be able to add some UI element to the rows to indicate that they are now ready to be selected. Is there a way I can add this UI element to all the rows in the tableview and change the position of existing elements without using a for loop?
I'm doing this currently:
for( var r = 0 ; r < tableView.data[0].rows.length ; r++){
tableView.data[0].rows[r].children[0].animate({left:50, duration:500});
tableView.data[0].rows[r].children[1].animate({left:50, duration:500});
tableView.data[0].rows[r].children[2].show();
}
It's slow, and sometimes fails halfway through.
I can also see the views cascading to the left one after the other instead of simultaneously.
I'd like something smooth like when we toggle tableview.editing = true
4 Answers
-
Jay. Did you ever work this out. I'm currently having the same issue with my tableview. I had just posted here:
Looping through Tableview to toggle selected row
Thanks
-
Maybe recreating the rows and using setData will do the trick.
-
Mmm, what about adding all the UI elements in the row, and depending on the state you have, to show or hide what you need? Would this work for you ?
-
Maybe caching the elements before you put it into the rows and accessing form here would be more faster.
var buttons = [b1,b2,b3,b4]; row1.add(b1)... ... for ( b in buttons ) { butons[b].hide(); }