0

I use titanium to develop iPhone application, in a tableView I set table moving property to true, after giving this property the row click event listener not working.

var contentArry = [];
var containerTbl  = Ti.UI.createTableView
({
    separatorStyle: Titanium.UI.iPhone.TableViewSeparatorStyle.NONE,
    backgroundColor: "transparent",
    hideSearchOnSelection: false,
    moving: true,
    width: 320,
    left: 0,
    top : 0,
    height : 480
});

for(i=0;i<5;i++)
{
    var containerRow = Ti.UI.createTableViewRow
    ({
        height: 65,
        width : 320,
        left : 0,
        backgroundColor: 'transparent',
        selectionStyle : Titanium.UI.iPhone.TableViewCellSelectionStyle.BLUE,
    }); 

    var nameLbl = Ti.UI.createLabel
    ({
        font: {fontSize: 15, fontWeight: 'bold', fontType: 'HaveticaLTStd'},
        textAlign : 'center'            
        color: '#5F5F5F',
        text : "MyName"
    })
    containerRow.add(nameLbl);
    contentArry.push(containerRow);

    containerRow.addEventListener('click',function(e){
        alert("Name : " e.row.children[0].text)
    });

}
containerTbl.data = contentArry;
jbalsas
  • 3,484
  • 22
  • 25
Praveen Kumar
  • 308
  • 1
  • 4
  • 18

2 Answers2

0

Try this,

You can add addEventListener on TableView object and perform any type of tasks...

   var containerTbl  = Ti.UI.createTableView({
    zIndex :99999999,
    separatorStyle: Titanium.UI.iPhone.TableViewSeparatorStyle.NONE,
    backgroundColor: "transparent",
    hideSearchOnSelection: false,
    width: 320,
    left: 0,
    top : 0,
    height : 480,


});
var contentArry=[];
for(i=0;i<5;i++)
{
    var containerRow = Ti.UI.createTableViewRow({
        title : "MyName"+i,
        height: 65,
        width : 320,
        left : 0,
        backgroundColor: 'transparent',
        //selectionStyle : Titanium.UI.iPhone.TableViewCellSelectionStyle.BLUE,
    }); 


    contentArry.push(containerRow);



}
containerTbl.data = contentArry;

containerTbl.addEventListener("click",function(e){
    alert("Name : " +e.row.title);

});

You can put all properties in your tableviewrow's properties like name1 : "xyz", name2 :"xyz",

and get like this e.row.name1 etc...

cheers...

MRT
  • 1,610
  • 15
  • 41
  • thanks, but I need event for each row to get some information from row child element.. please see my edited question.... – Praveen Kumar Jun 12 '13 at 12:59
0

Try to set moveable : true or editable : true in TableViewRow.

Refer this: http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.UI.TableView-property-moving

Porwal
  • 330
  • 5
  • 18