Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-2724] iOS: selectRow fails in TableViews

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2012-05-11T16:31:56.000+0000
Affected Version/sRelease 1.5.0
Fix Version/sRelease 2.1.0, Sprint 2012-10 API
ComponentsiOS
LabelsSupportTeam, api, module_tableview, qe-testadded
ReporterRonnie Swietek
AssigneeVishal Duggal
Created2011-04-15T03:27:50.000+0000
Updated2012-07-10T12:52:29.000+0000

Description

According to the API:

http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.UI.TableView-object"> http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.UI....
selectRow - programmatically select a row

I've tested this on the iphone and ipad and they both fail to select a row. Attached below is a quick example.

edit:
It seems this bug happens when there are rows that go off the device screen. If I do like 10 or 11 rows it works fine. 12+ it breaks (on iphone)

On the iPad obviously you can fit more rows so this number will be higher.

Attachments

FileDateSize
cm-movie-1.mov2011-04-15T03:27:51.000+00005222671
selectrow_test.zip2011-04-15T03:27:53.000+00001815900

Comments

  1. Ronnie Swietek 2011-04-15

    attached a new dumbed down version

  2. Ronnie Swietek 2011-04-15

    Titanium 1.5.1 and iphone sdk 4.2

  3. Ronnie Swietek 2011-04-15

    am I doing something wrong when posting bugs? Mine never seem to get assigned to anyone. Here is a thread of other people claiming its a bug

    http://developer.appcelerator.com/question/96361/selectrow-on-a-tableview"> http://developer.appcelerator.com/question/96361/selectrow-on-a-tab...

  4. Ronnie Swietek 2011-04-15

    Can we get some attention on this? TableView is a pretty common UI element that should be at least medium priority.

  5. Ronnie Swietek 2011-04-15

    I found that selectRow works in 1.5.0 but not 1.5.1

  6. Ronnie Swietek 2011-04-15

    ok I lied. I've come to this conclusion

    It seems this bug happens when there are rows that go off the device screen. If I do like 10 or 11 rows it works fine. 12+ it breaks (on iphone)

    On the iPad obviously you can fit more rows so this number will be higher.

  7. Jeremy Swensen 2011-04-15

    I've noticed the same problem. I can reproduce the problem with only 5 rows when the height of the rows are set to 100px. I agree with Ronnie that when the rows go off the device screen the selectRow method will not work.

    I have also noticed that selecting a single row causes another row to automatically be selected. For instance, if I click the first row and select it, and then scroll down another row was automatically selected.

    Is there a workaround for this?

  8. Ronnie Swietek 2011-04-15

    Why wasn't a bug like this fixed in the 1.6 release?? I screen recorded a test app I made and you can see the list is lengthy...about 30 rows..If I start scrolling, random rows start to get selected. Note, I have no clicked on any rows..uhmmm??

    Don I am selecting you as the "who is responsible". I've seen you get many things fixed around here..well and I am just not familiar with anyone else.

  9. Ronnie Swietek 2011-04-15

    Thanks for addressing this Don, but low priority? The list is pretty unusable at this point. Also what does TBS stand for?

  10. Don Thorp 2011-04-15

    I've moved it over to the iOS lead to classify. It's not my position to classify the priority of his items. TBS means "To Be Scheduled"

  11. Jolon 2011-04-15

    I've found a solution to this which is described here:

    http://developer.appcelerator.com/question/96361/selectrow-on-a-tableview"> http://developer.appcelerator.com/question/96361/selectrow-on-a-tab...

    In essence, TiUITableView delays setting the selection of the table view until the last cell is display (for some reason). However, if the last cell is not visible then it won't trigger the selection.

    My work around is to remove the check for the last row, so it will now trigger when the first cell is displayed. This works fine because it will only trigger once due to the initiallyDisplayed variable being set to YES within the if statement.

    In TiUITableView.m change tableView:willDisplayCell:

    if (initiallyDisplayed==NO && [indexPath section]==[sections count]-1 && [indexPath row]==[section rowCount]-1)

    to:

    if (initiallyDisplayed==NO)

  12. Slim McKinsley 2011-09-09

    Bump, can we please get this bug prioritized? I am waiting on this fix to release an iPad app. Also waiting on a related fix for tableView.scrollToIndex() to work on iPad.
  13. Nick Milner 2011-10-10

    Bump. Bump. I too am waiting on a fix for this. Any ETA on a fix ?
  14. James Wragg 2011-10-31

    I'm being plagued with this bug too. Here is a clear screencast of the issue: http://screencast.com/t/xXHuMoXc And another test-case here: https://gist.github.com/1329382 Any ETA?
  15. James Wragg 2012-03-03

    Bump. The .selectRow() method does not work, it would be great to get some kind of ETA of when it will. Thanks.
  16. Vishal Duggal 2012-05-10

    Test Case
        
        var win = Titanium.UI.createWindow({  
        	layout:'vertical',
            backgroundColor:'#fff'
        });
        
        var createSection = function(title,rowCount){
        	var s1 = Titanium.UI.createTableViewSection({
        		headerTitle:title
        	});
        	
        	for (i=0;i<rowCount;i++)
        	{
        		var row = Ti.UI.createTableViewRow({
        			title:'Row '+i+' of '+title
        		})
        		s1.add(row);
        	}
        	return s1;
        }
        
        var tblView = Ti.UI.createTableView({})
        
        var data = [];
        data.push(createSection('One',5));
        data.push(createSection('Two',15));
        data.push(createSection('Three',25));
        tblView.setData(data);
        
        
        var wrapper = Ti.UI.createView({
        	height:Ti.UI.SIZE,
        	layout:'horizontal'
        })
        
        var input = Ti.UI.createTextField({
        	left:'5%',
        	width:'40%',
        	top:5,
        	bottom:5,
        	height:40,
        	borderStyle: Ti.UI.INPUT_BORDERSTYLE_BEZEL,
        	keyboardType:Ti.UI.KEYBOARD_NUMBER_PAD,
        })
        
        wrapper.add(input);
        
        var btn = Ti.UI.createButton({
        	left:'5%',
        	width:'40%',
        	top:5,
        	bottom:5,
        	height:40,
        	title:'Select'
        })
        
        btn.addEventListener('click',function(){
        	input.blur();
        	var val = input.value;
        	if(val && val.length > 0)
        	{
        		tblView.selectRow(val);
        	}
        })
        
        wrapper.add(btn);
        
        win.add(wrapper);
        
        
        win.add(tblView);
        
        
        win.open();
        
  17. Michael Pettiford 2012-06-20

    Closing issue Tested with Ti Studio build 2.1.0.201206200844 Ti Mobile SDK 2.1.0.v20120619172256 hash rd3a84b13 OSX Lion 10.7.3 iPhone 4S OS 5.1 The expected behavior is shown

JSON Source