GK_
GK_

Reputation: 1212

Appcelerator Titanium TableRowView click

I using Android application using Titanium Appcelerator.. I trying to click and retrieve a row view value from my table . i getting "undefined" ..help me to retrieve my row value..

Here is my code...

var row = Ti.UI.createTableViewRow();
row.title = 'row';
row.postid = '' + post.id;
row.addEventListener('longclick', function(e) {
    Titanium.API.info(evt.postid);
});

Upvotes: 1

Views: 129

Answers (1)

daniula
daniula

Reputation: 7028

You mistyped parameter name, instead of:

row.addEventListener('longclick', function(e) {
    Titanium.API.info(evt.postid);
});

it should be:

row.addEventListener('longclick', function(e) {
    Titanium.API.info(e.postid);
});

Also in case of TableView and rows it's better to create event listener on whole table like this:

var table = Ti.UI.createTableView();
var row = Ti.UI.createTableViewRow();
row.title = 'row';
row.postid = '' + post.id;
table.setData([row]);

table.addEventListener('longclick', function(e) {
    Titanium.API.info(e.row.postid);
});

Upvotes: 2

Related Questions