Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There are two ways to set the rows of a table, you can create custom rows, or create JSON objects that have the attributes of the row object. Both cases have different ways of accessing the row, either the <code>row</code> object or the <code>rowData</code> object, <a href="http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.UI.TableView-event-click" rel="nofollow">from the docs</a>:</p> <blockquote> <p>When the row is created implicitly using a JavaScript dictionary object, use [the rowData property] rather than row to access any custom row properties. Here's an example of creating a row implicitly, which is not the recommended way.</p> </blockquote> <p>In your example, since you did not create the row objects implicitly, but explicitly, you can access the clicked row from the <code>row</code> attribute of the event like this:</p> <pre><code>tableView.addEventListener("click", function(e){ // Get the [TableViewRow](http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.UI.TableViewRow) object var theRow = e.row; // Get the children var rowChildren = theRow.children; // Here are your objects in the row var imgInRow = rowChildren[0]; var bgBarInRow = rowChildren[1]; var titleInRow = rowChildren[2]; // Here is the title var rowTitle = titleInRow.text; }); </code></pre> <p>Alternatively, in both cases, you could always use the index to look up the row object like this:</p> <pre><code>tableView.addEventListener("click", function(e){ // Get the index of the row var ndx = e.index; // Get the row, this only works if you have not added sections var row = tableView.data[ndx]; }); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload