rowData return null for Ti.UI.TableView when used with section in Android

You must Login before you can answer or comment on any questions.

Hi All,

e.rowData return null value for Ti.UI.TableView control's click event specially when I have added section in table. This happen only in Android since on iPhone working perfectly fine. I have seen similar bug on bug report and indicate resolved on around March,2012 but seems miss for Android. Here is text code that cause issue. Let me know I am doing wrong.

function TestWin() {
    Ti.UI.backgroundColor = 'white';
    var win = Ti.UI.createWindow();
 
    var sectionFruit = Ti.UI.createTableViewSection({ headerTitle: 'Fruit' });
    sectionFruit.add(Ti.UI.createTableViewRow({ title: 'Apples' }));
    sectionFruit.add(Ti.UI.createTableViewRow({ title: 'Bananas' }));
 
    var sectionVeg = Ti.UI.createTableViewSection({ headerTitle: 'Vegetables' });
    sectionVeg.add(Ti.UI.createTableViewRow({ title: 'Carrots' }));
    sectionVeg.add(Ti.UI.createTableViewRow({ title: 'Potatoes' }));
 
    var table = Ti.UI.createTableView({
      data: [sectionFruit, sectionVeg]
    });
 
    win.add(table);
    win.open();
 
    var sectionFish = Ti.UI.createTableViewSection({ headerTitle: 'Fish' });
    sectionFish.add(Ti.UI.createTableViewRow({ title: 'Cod' }));
    sectionFish.add(Ti.UI.createTableViewRow({ title: 'Haddock' }));
 
    table.setData([ sectionFish, sectionFruit, sectionVeg ]);
 
    table.addEventListener('click', function(e) {
        alert(e.rowData.title);
    });
 
    return win;
};
 
module.exports = TestWin;

3 Answers

Accepted Answer

Hi Pritesh Patel i found Your Problem And also the solution of your Problem what you need to do is just replace your alert at click event of table by

alert(e.row.title)
and you will get your solution. and please mark the answer as permanent if your problem is solved

— answered 8 months ago by Ishan Singh
answer permalink
4 Comments
  • Hi Ishan,

    I got that work around but wasn't it should work with RowData as well since it work fine with simple table view as well as in iPhone with section.

    Thanks for your time.

    — commented 8 months ago by Pritesh Patel

  • Hi Sometimes It happens that some properties are supported in ios but not not in android. so may be that's the problem

    — commented 8 months ago by Ishan Singh

  • Sorry I am pulling it too much but it work with Adroid as well but only if TableView created without section. Anyway, thanks for your time, your solution will work for me.

    — commented 8 months ago by Pritesh Patel

  • Show 1 more comment

Hi Pritesh, for a general advice whenever you find this kind of problem then simple use this way to find what you are getting.

table.addEventListener('click', function(e) {
        alert(JSON.stringify(e));  // then use the property accordingly
    });

— answered 8 months ago by Ashish Nigam
answer permalink
1 Comment
  • Thanks for your suggestion. I have another workarround that Ishan has suggested but just wanted to point it out that wasn't it bug?

    — commented 8 months ago by Pritesh Patel

Your Answer

Think you can help? Login to answer this question!