<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>Snipplr</title>
    <description>Recent snippets posted on Snipplr.com</description>
    <link>https://snipplr.com/</link>
    <lastBuildDate>Wed, 10 Jun 2026 03:24:09 +0000</lastBuildDate>
    <item>
      <title>(JavaScript) Titanium Multiselect TableViewRows - rhyski</title>
      <link>https://snipplr.com/view/50907/titanium-multiselect-tableviewrows</link>
      <description>&lt;p&gt;**(Titanium) JavaScript**&#13;
&#13;
Currently Ti.UI.TableViews don't have native multiple selection behaviour&#13;
&#13;
This function will create and return TableView instance which tracks rows that are *selected* using a supplied array to store the selected indexes.&#13;
When a row is clicked it toggles its *selected* state and adds/removes from the array.&#13;
**Custom events added to the table**&#13;
&#13;
*    onrowselect(e)&#13;
*    onrowunselect(e)&#13;
&#13;
**e** will be the same event object the originating click event received.&#13;
## Example ##&#13;
&#13;
    var dataRows []; // collection of TableViewRows&#13;
    var params = {data:dataRows}; // any normal TableView params&#13;
    var indexes = [];&#13;
    var tableview = NAMESPACE.tableViewMultiSelectRows(params,indexes);&#13;
    tableview.addEventListener('onrowselect',function(e){&#13;
	    Ti.API.log('select');&#13;
	    e.row.backgroundColor = '#f00';&#13;
    });&#13;
    tableview.addEventListener('onrowunselect',function(e){&#13;
	    Ti.API.log('unselect');&#13;
	    e.row.backgroundColor = '#fff';&#13;
    });&#13;
    tableview.addEventListener('click',function(e){&#13;
	    Ti.API.log(indexes);&#13;
    });&#13;
**NB: this is not suitable for tables where rows are added/removed dynamically - without modification**&#13;
&#13;
Tried setting the array on the table itself but that does not work and always returns an empty array. Also storing the row itself in the array rather than index does not work as it never finds indexOf(e.row) so e.row must be a unique ref to the row each time???&lt;/p&gt;</description>
      <pubDate>Mon, 21 Mar 2011 11:41:36 UTC</pubDate>
      <guid>https://snipplr.com/view/50907/titanium-multiselect-tableviewrows</guid>
    </item>
  </channel>
</rss>
