Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-5982] Can't get access to a TableView's rows (Android)

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2012-01-04T13:10:24.000+0000
Affected Version/sRelease 1.7.0, Release 1.8.0
Fix Version/sSprint 2011-44, Release 1.7.6, Release 1.8.0.1
ComponentsAndroid
Labelsdata, module_tableviewrow, qe-testadded
ReporterShannon Hicks
AssigneeAllen Yeung
Created2011-11-03T12:27:59.000+0000
Updated2012-01-04T13:10:24.000+0000

Description

I need to get an array of a TableView's rows. I tried two different ways, but both produce errors. They are in the code below. Please note, that while this code is designed to delete a row, that is not the goal in my usage... I need access to the TableViewRow objects themselves. Both examples work in iOS.
var win = Ti.UI.createWindow();

var myTableView = Ti.UI.createTableView();

var row = Ti.UI.createTableViewRow({
	height:80,
	backgroundColor:'#c00',
});

myTableView.appendRow(row);

win.add(myTableView);

win.addEventListener('open',function(){
	setTimeout(function(){
		Ti.API.debug(JSON.stringify(myTableView));
		var tableRows = myTableView.data[0].rows;
		Ti.API.debug(JSON.stringify(tableRows));
		tableRows.pop(); // returns the error org.mozilla.javascript.EcmaError: TypeError: Cannot find default value for object.
		myTableView.data = tableRows;
	},2000); // two seconds after the window opens, remove the red row
});

/* you can swap out the open event listener with this one to see my alternative also fail
win.addEventListener('open',function(){
	setTimeout(function(){
		Ti.API.debug(JSON.stringify(myTableView));
		var tableRows = myTableView.sections[0].rows; // returns the error Message: Java class "java.util.ArrayList" has no public instance field or method named "0".
		Ti.API.debug(JSON.stringify(tableRows));
		tableRows.pop();
		myTableView.data = tableRows;
	},2000); // two seconds after the window opens, remove the red row
});
*/

win.open();

Attachments

FileDateSize
objectType.js2011-11-03T14:14:59.000+0000485

Comments

  1. Paul Dowsett 2011-11-03

    Shannon, please leave the assignee field to automatic when creating tickets. Many thanks
  2. Natalie Huynh 2011-11-03

    Android is not returning array when called so error is thrown during compile because of the pop statement. Created a short simple test for drillbit and return type fails
  3. Paul Dowsett 2011-11-03

    Natalie If you are aware of this issue, you are welcome to take ownership of the ticket and move it to TiMob. Thanks
  4. Paul Dowsett 2011-11-03

    oh, my apologies - you have done. Thank you! :)
  5. Allen Yeung 2011-11-04

    I would try the following workaround to remove a table row:
       var win = Ti.UI.createWindow();
       
       var myTableView = Ti.UI.createTableView();
       
       var row = Ti.UI.createTableViewRow({
       	height:80,
       	backgroundColor:'#c00',
       });
       
       myTableView.appendRow(row);
       win.add(myTableView);
       
       win.addEventListener('open',function(){
       	setTimeout(function(){
       		Ti.API.debug(JSON.stringify(myTableView));
       		var tableRows = myTableView.data[0].rows;
       		Ti.API.debug(JSON.stringify(tableRows));
       		myTableView.data[0].remove(row); // returns the error org.mozilla.javascript.EcmaError: TypeError: Cannot find default value for object.
       
       	},2000); // two seconds after the window opens, remove the red row
       });
       
       win.open();
       
    You can also access a single table row via something like: myTableView.data[0].rows[0]
  6. Don Thorp 2011-11-04

    Fixed on 1_7_X.
  7. Don Thorp 2011-11-04

    Needs to be checked on 1.8.0 after v8 merge.
  8. Josh Roesslein 2011-11-09

    Looks to have been resolved with V8 changes. I don't believe this patch is required now after v8 merge.
  9. Josh Roesslein 2011-11-10

    Function test for 1.8.0.1 passed.
  10. Natalie Huynh 2011-12-06

    Tested with 1.8.0.1.v20111205164258 v8/rhino on Galaxy 10.1 (3.1) Droid 1 (2.2.2) Nexus S (2.3.6) Emulator (4.0)
  11. Natalie Huynh 2012-01-04

    Open to add label

JSON Source