Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Add data to a row

I have a drill down menu. Can I add data to the row so when I click on a row, I have access to it in the event? When I alert(event) in the click event I can see a bunch of information pertaining to that row so I am assuming I can. I just don't know how.

— asked October 14th 2010 by Ronnie Swietek
  • data
  • row
0 Comments

2 Answers

  • I think this is the solution, if i understand it correct:

    //First create a table
    var table = Ti.UI.createTableView({
        top:0, 
        height: 'auto'
    });
    
    //Create a row
    var rows = [];
    rows[0] = Ti.UI.createTableViewRow({
        height: 'auto', 
        id: 'yourId'  //This variable isn't visible in the API's that because you can add every variable you want of an object
    });
    
    //Create a label
    var label = Ti.UI.createLabel({
        color: '#000000',
        text: 'Your text',
        top: 1,
        left: 1,
        width: 110
    });
    
    rows[0].add(label);
    table.setData(rows);
    
    table.addEventListener('click',function(e){
        if( e.row.id == 'yourId' )
        {
            label.text = 'You clicked on yourId';
        }
    });
    
    — answered October 15th 2010 by Jacob van Dam
    permalink
    0 Comments
  • I've answered my own post again.

    yourRow.yourCustomData = 'your data';

    accessed:

    event.rowData.yourCustomData

    — answered October 14th 2010 by Ronnie Swietek
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.