Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

TableView > Enable EDIT Mode and SELECT multiple rows

I'm looking to do something similar to what you see in MAIL where you click EDIT and little circles appear on left side. Then you can select multiple rows and run an action on those rows (delete, move, etc) from a menu at the bottom.

I know there's EDIT which causes DELETE buttons to appear on the left side to delete one row, but what I want is to be able to select multiple rows and run a function on click of a toolbar button.

Does that exist in the API in some way or do I have to build this stuff manually (yikes!)

thanks

Fish

— asked September 30th 2010 by Dave F
  • edit
  • multiple
  • select
  • tableview
2 Comments
  • Anyone have any thoughts on best way to do this? Thanks!

    — commented October 8th 2010 by Dave F
  • Hey D, were you able to get the circles to appear on the left side? I'm not seeing any API for it.

    — commented February 2nd 2011 by Kelly Redd

3 Answers

  • Has anyone found a way to do this? I see there's a listing in the bug/feature tracker for something like this. But its not scheduled to be worked on.

    https://appcelerator.lighthouseapp.com/projects/32238/tickets/842-create-table-view-options-api

    — answered January 24th 2011 by Dave F
    permalink
    0 Comments
  • You could do something along the lines of:

    1. add a boolean variable to each row, such as row.isSelected
    2. add an 'edit' or 'select multiple rows' button on the title bar (or wherever)
    3. create an eventListener on the table that listens for taps on rows and sets that variable to true if selected (if the edit button is active)
      tableView.addEventListener('click', function(e)
      
    4. push all "selected" rows into an array
      if (e.rowData.isSelected) { someArray.push(e.row) //push row into an array
      
    5. do what you want with the rows in the array

    Of course, that's not the most elegant way of putting it, but I hope the logic is clear. :)

    — answered January 29th 2011 by Rj S.
    permalink
    0 Comments
  • Anyone know why this doesn't work as expected:

    tableview.addEventListener('click',function(e){
        Ti.API.log('e.row.bool_selected',e.row.bool_selected);
        e.row.bool_selected = e.row.bool_selected ? 0 : 1;
        e.row.indicator.backgroundColor = (e.row.bool_selected ? '#0F0' : '#F00');
        Ti.API.log('e.row.bool_selected',e.row.bool_selected);
    });
    

    The logs come out as expected and the indicator (a simple square view at the moment) does toggle between green and red but if it toggles to green and then I click another row the one that was green toggles back to red?
    I also tried e.rowData.bool_selected but had same result.

    Is there a setting for tableViews to enable multiple selection its acting as if you can only ever select one at a time

    — answered March 17th 2011 by Rhys Burnie
    permalink
    1 Comment
    • Nevermind I worked out another means to multiple select

      — commented March 17th 2011 by Rhys Burnie
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.