Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-13055] Android: tableview events: missing "row" property

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2013-04-01T17:20:36.000+0000
Affected Version/sRelease 3.1.0, 2013 Sprint 07 Core, 2013 Sprint 07
Fix Version/sRelease 3.1.0, 2013 Sprint 07 Core, 2013 Sprint 07
ComponentsAndroid
Labelsqe-testadded, triage
ReporterMartin Guillon
AssigneeAllen Yeung
Created2012-10-16T10:39:51.000+0000
Updated2013-04-19T11:09:20.000+0000

Description

On android, when firing an event on a tableview, not all events a correctly filled with "row" property. Only click directly on the row (not subview) and longpress are. Other events like should be filled to
var win = Ti.UI.createWindow();
win.backgroundColor = 'white';
var data = [];

for (var x=0;x<4;x++)
{
	var label = Ti.UI.createLabel({
		text:'Row Label ' + x,
		height:'auto',
		width:'auto',
		color:'#336699',
		left:10
	});
	var row = Ti.UI.createTableViewRow({height:50});
	row.add(label);
	data.push(row);
}

// create table view
var tableview = Titanium.UI.createTableView({
	data:data
});

function log(e) {
        if (e.row)
          Ti.API.info('we got row property for event ' + e.type);
}
tableview.addEventListener('longpress', log);
tableview.addEventListener('swipe', log);
tableview.addEventListener('touchstart', log);
tableview.addEventListener('touchend', log);
tableview.addEventListener('touchcancel', log);

win.add(tableview);
win.open();

Comments

  1. Jan Helleman 2012-10-16

    I can second this issue. The object passed to the click event is the actual clicked object, not the row. For me there is no way to identify which row was clicked, and right now I cannot access any extra parameters added to the row, without extra coding...
  2. Lorenzo 2012-12-17

    same problem here, no e.row.id in longpress click, so I can't identify it.
  3. Martin Guillon 2012-12-17

    Actually i fixed this in my branch. Will have to point the commits and make a pull request out of it
  4. Daniel Sefton 2013-02-13

    Martin: Do you have a pull request ready for this yet? Thanks!
  5. Martin Guillon 2013-02-14

    here you go https://github.com/appcelerator/titanium_mobile/pull/3872 But read the details, i also changed the method to get the current row
  6. Sunila 2013-03-16

    Fill row information for all events fired from TableViewRowProxy https://github.com/appcelerator/titanium_mobile/pull/3975
  7. Allen Yeung 2013-03-26

    PR: https://github.com/appcelerator/titanium_mobile/pull/4039
  8. Vishal Duggal 2013-03-29

    Expanded test case that checks the source of the event as well.
       var win = Ti.UI.createWindow();
       win.backgroundColor = 'white';
       var data = [];
        
       for (var x=0;x<4;x++)
       {
           var label = Ti.UI.createLabel({
               text:'Row Label ' + x,
               height:'40 dp',
               width:'80%',
               color:'white',
               backgroundColor:'blue',
               left:10
           });
           var row = Ti.UI.createTableViewRow({height:'50 dp'});
           row.add(label);
           data.push(row);
       }
        
       // create table view
       var tableview = Titanium.UI.createTableView({
           data:data
       });
        
       function log(e) {
               if (e.row)
                 Ti.API.info('we got row property for event ' + e.type +' '+e.source);
       }
       tableview.addEventListener('longpress', log);
       tableview.addEventListener('swipe', log);
       tableview.addEventListener('touchstart', log);
       tableview.addEventListener('touchend', log);
       tableview.addEventListener('touchcancel', log);
       tableview.addEventListener('click', log);
        
       win.add(tableview);
       win.open();
       
  9. Vishal Duggal 2013-04-01

    https://github.com/appcelerator/titanium_mobile/pull/4039 merged
  10. Allen Yeung 2013-04-04

    Additional null check https://github.com/appcelerator/titanium_mobile/pull/4078
  11. Allen Yeung 2013-04-04

    backport: https://github.com/appcelerator/titanium_mobile/pull/4079
  12. Shyam Bhadauria 2013-04-06

    All events defined for row in app.js are being logged now. Environment used for verification - SDK: 3.1.0.v20130405170202 Studio:3.1.0.201304011603 Device: Samsung GALAXY tab (3.2) and Samsung Galaxy Nexus Android 4.0.2
  13. Paras Mishra 2013-04-19

    Added the testcase in the testsuite under TableView.

JSON Source