Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-8802] Android: Accessing row and rowData properties (non-propertyAccessors) has different results for TableView

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionWon't Fix
Resolution Date2012-09-18T17:41:01.000+0000
Affected Version/sRelease 2.1.0
Fix Version/sSprint 2012-19 API, 2012 Sprint 19
ComponentsAndroid
LabelsSupportTeam, api, parity, regression
ReporterPing Wang
AssigneeHieu Pham
Created2012-04-19T16:23:36.000+0000
Updated2013-03-13T15:06:07.000+0000

Description

Test case:

var win = Ti.UI.createWindow({
    backgroundColor:'white'
});
 
win.open();
 
// CASE 1
 
var data = [
    {title:'Row 1', hasChild:true, color:'red', selectedColor:'#fff', special:'special 1'},
    {title:'Row 2', hasDetail:true, color:'green', selectedColor:'#fff', special:'special 2'},
];
 
// create table view
var tableview = Titanium.UI.createTableView({
    top: 20,
    height: 200,
    data:data,
    borderColor: 'orange',
    borderWidth:'5',
    separatorColor:'black',
    headerTitle:'Table 1 without using createTableViewRow'
});
 
win.add(tableview);
 
// create table view event listener
tableview.addEventListener('click', function(e)
{
    showClickEventInfo(e);
});
 
function showClickEventInfo(e) {
    var row = e.row;
    var rowdata = e.rowData;
    alert('Row Special: ' + row.special);
    alert('Row Data Special: ' + rowdata.special);
}
 
 
// CASE 2
 
var data1 = [];
 
data1[0] = Ti.UI.createTableViewRow({hasChild:true,title:'Row 1', special:'special 1'});
data1[1] = Ti.UI.createTableViewRow({hasDetail:true,title:'Row 2', special:'special 2'});
 
 
// create table view
var tableview1 = Titanium.UI.createTableView({
    top: 240,
    borderColor: 'orange',
    borderWidth:'5',
    height: 200,
    separatorColor:'black',
    data:data1,
    headerTitle:'Table 2 using createTableViewRow'
});
 
win.add(tableview1);
 
function showClickEventInfo1(e) {
    var row = e.row;
    var rowdata = e.rowData; 
    alert('Row Special: ' + row.special);
    alert('Row Data Special: ' + rowdata.special);
}
 
 
// create table view event listener
tableview1.addEventListener('click', function(e)
{
    showClickEventInfo1(e);
});
In the first tableview, rows are created implicitly using JS Object and the second tableview creates rows explicitly using createTableViewRow method. The above code gives the same result for both tableview in iOS.

Comments

  1. Chaim Krause 2012-07-03

    I have code that worked in 2.0.2GA SDK, that is now broke in 2.1.0 SDK. I have a click event listener on a TableView and rowData is undefinded in the event callback.
  2. Hieu Pham 2012-09-12

    If you're creating rows implicitly using JS objects, any custom properties set upon creation can only be accessed via "rowData" property (i.e e.rowData.special). If you're creating rows explicitly - using Ti.UI.createTableViewRow(), any custom properties set upon creation can be accessed via the row object and "rowData" property. This is a platform limitation. We don't recommend creating rows implicitly. Documentation will be updated to prevent future confusion. @Chaim What you describe seem to be a different issue. If it's still happening, please file a separate JIRA.
  3. Arthur Evans 2012-09-18

    Documentation added for this case.
  4. Natalie Huynh 2012-12-04

    Closing as won't fix and documented

JSON Source