Note that there are some explanatory texts on larger screens.

plurals
  1. POAccessing custom rows of a TableView
    primarykey
    data
    text
    <p>I am pushing items to a data array and then adding these to a rowData array in order to create custom rows for a table. I need to know how to access these when a user clicks a specific row. I was previously using e.rowData, title etc. for accessing these elements when I had a basic table but now that it is a custom table, this isn't working. Don't worry about the parsing bit, that all works fine. All help appreciated!</p> <pre><code>data.push({ title: items.item(i).getElementsByTagName("title").item(0).text, leftImage: str.match(patt1) !== null ? str.match(patt1)[0] : 'image_news.png', dataToPass: items.item(i).getElementsByTagName("description").item(0).text, hasChild: true, js:"external.js" }); } var rowData=[]; for(i=0;i&lt;data.length;i++){ var img= Titanium.UI.createImageView({ image:data[i].leftImage, left:0, bottom:5, height: 100, width: 100 }); var bgBar=Titanium.UI.createView({ height:110, width: "100%", bottom:0, left:0, backgroundColour: "#000", opacity: 0.6 }); var title=Titanium.UI.createLabel({ text:data[i].title, color: 'black', left: 105 }); var row=Titanium.UI.createTableViewRow({ height: "auto", hasChild: "true", js:"external.js", dataToPass: data[i].dataToPass }); row.add(img); row.add(bgBar); row.add(title); rowData.push(row); console.log("row shiznick" + rowData); } tableView.setData(rowData); tableView.addEventListener("click", function (e){ console.log("HERE SOURCE.TITLE ------------------"+e.row.title); console.log("YOYOOYOYO------------"+e.source.title); console.log("IS THIS IT---------------"+e.children[0]); console.log("HERE IS THE SOURCE -----------------------------"+ e.source); console.log("HERE SOURCE.LEFTIMAGE REG EXP3 ------------------"+e.row.leftImage); console.log("HERE SOURCE.ClassName ------------------"+e.source.className); console.log("HERE HASCHILD ------------------"+e.rowData.hasChild); console.log("HERE DATATOPASS ------------------"+e.row.dataToPass); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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