[AC-2187] iOS: TableView index without index attribute
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Closed |
Resolution | Cannot Reproduce |
Resolution Date | 2013-07-15T18:08:57.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | n/a |
Labels | index, ios, tableview |
Reporter | Matej |
Assignee | Mauro Parra-Miranda |
Created | 2013-05-13T12:00:42.000+0000 |
Updated | 2016-03-08T07:41:10.000+0000 |
Description
If I have table view with index (Index contain whole alphabet) ,but in the table view I've got only values with "A", "B", "C", "D" (In all 300 - for example). When I click on the letter A/B/C/D there isn't no problem, I can see values which start with letter... But when I click for example to letter "E" or higher (Values where isn't set index in index array) then TableView automatically scroll to top on first letter "A". This is a big problem when I have values A->E then for example F/G is empty and rest is also set. When somebody click on the letter "F" tableview show letter "A". It has to stay on the last letter no scroll to first...
I know that I can solve this "somehow" ,but that is annoying. Much better is fixed the "main" bug than every time solve... Thanks you so much
* app.js (From KitchenSink)*
var win = Titanium.UI.createWindow();
var data = [
{title:'Alan (click to change index)', hasChild:true, header:'A'},
{title:'Alice', hasDetail:true},
{title:'Alexander'},
{title:'Amos'},
{title:'Alonzo'},
{title:'Brad', header:'B'},
{title:'Brent'},
{title:'Billy'},
{title:'Brenda'},
{title:'Callie', header:'C'},
{title:'Cassie'},
{title:'Chris'},
{title:'Cameron'},
{title:'Don', header:'D'},
{title:'Dilbert'},
{title:'Deacon'},
{title:'Devin'},
{title:'Darin'},
{title:'Darcy'},
{title:'Erin', header:'E'},
{title:'Erica'},
{title:'Elvin'},
{title:'Edrick'},
{title:'Frank', header:'F'},
{title:'Fred'},
{title:'Fran'},
{title:'Felicity'},
{title:'George', header:'G'},
{title:'Gina'},
{title:'Gary'},
{title:'Herbert', header:'H'},
{title:'Henry'},
{title:'Harold'},
{title:'Ignatius', header:'I'},
{title:'Irving'},
{title:'Ivan'},
{title:'Dr. J', header:'J'},
{title:'Jefferson'},
{title:'Jenkins'},
{title:'Judy'},
{title:'Julie'},
{title:'Kristy', header:'K'},
{title:'Krusty the Clown'},
{title:'Klaus'},
{title:'Larry', header:'L'},
{title:'Leon'},
{title:'Lucy'},
{title:'Ludwig'},
{title:'Mary', header:'M'},
{title:'Mervin'},
{title:'Malcom'},
{title:'Mellon'},
{title:'Ned', header:'N'},
{title:'Nervous Eddie'},
{title:'Nelson'},
{title:'The Big O', header:'O'},
{title:'Orlando'},
{title:'Ox'},
{title:'Pluto', header:'P'},
{title:'Paris'},
{title:'Potsie'}
];
var tableview = Titanium.UI.createTableView({ data:data });
var index = [
{title:'A',index:0},
{title:'B',index:5},
{title:'C',index:9},
{title:'D',index:13},
{title:'E',index:19},
{title:'F',index:23},
{title:'G',index:27},
{title:'H'},
{title:'I',index:33},
{title:'J',index:36},
{title:'K',index:41},
{title:'L',index:44},
{title:'M',index:48},
{title:'N',index:52},
{title:'O',index:55},
{title:'P',index:(data.length -1)}
];
tableview.index = index;
win.add(tableview);
win.open();
(Click on "A" and slow slide down to "P". If you will be on the letter "H" where isn't set any index param you will see first letter ("A"). That is the bug. If there isn't any index table can't show first letter. It must stay on last index/letter...)
Hi Matej, Please provide a simple reproducible test case that we can drop into an app.js and run. Thanks!
Done ;)
Please can you edit "Needs more info". I already added info... Thanks
???
Hi Matej, I can't reproduce this on iOS 6 simulator with Ti SDK 3.1 GA or 3.2 CI. Clicking E scrolls to E values, F scrolls to F values etc.
Hi, what about H?
Oh I see, the description needs changing...
Didn't see the part below the test case, my apologies.
So basically you're saying that if no index attribute is set, then clicking on the index shouldn't scroll to the top, it should just stay put and do nothing? By default the index is 0, so in that respect it makes sense.
Exactly. For example application Contacts (Alphabetical list...) that you can find in an iPhone is working like this. It is much better than...
Yes, you're right. I'll clean up the issue and move to Ti Mob. Tested and confirmed on iOS 6 simulator with Ti SDK 3.1.1 GA and 3.2 CI.
Actually, the behavior I saw in the contacts app was that it scrolled to the nearest index with content when tapping an index with no content. The behavior in Titanium is exactly the same. The fact is that if you don't set an index attribute, the index attribute is 0 by default. In the contacts app I guess they do set the index attribute for all alphabet values. So my question is why do you need to omit the index attribute for some indexes?
OK so when I want to have in my application same behavior like in contacts app I have to set every index. Isn't it easier to make it automatically by Titanium?
Correct. Well I suppose Titanium could set the index to be the array position, but I don't see much of a need to make this change (there are only 26 letters in the alphabet you need to set it for), and it may break apps which rely on being able to set the index manually.