-
27 Nov 2012 5:45 AM #1
Bug in the 2.1 list implementation
Bug in the 2.1 list implementation
Hello Sencha,
I think we've found a bug in the new list implementation provided with Sencha 2.1.
The method
The indexOffset is the absolute list index of the top item in the view list (use list.getViewItems()), but the item indices (dataIndex) seems to be calculated using absolute index in the onTranslate method. Therefore an indexOffset > 0 will yield a bad index for the item.Code:getItemIndex: function(item) { var index = item.dataIndex; return (index === -1) ? index : this.indexOffset + index; },
-
27 Nov 2012 6:23 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,714
- Vote Rating
- 438
Thanks for the report! I have opened a bug in our bug tracker.
-
27 Nov 2012 6:26 AM #3Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,714
- Vote Rating
- 438
I used the list example and scrolled down to the D group and did this:
which gave me 36 as the index of the first D record. I then did this:Code:var list = Ext.ComponentQuery.query('list')[0], idx = list.getStore().indexOf(list.listItems[0].getRecord());
and it gave me 72.Code:var list = Ext.ComponentQuery.query('list')[0], idx = list.getItemIndex(list.listItems[0]);Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
3 Dec 2012 7:47 AM #4Sencha - Sencha Touch Dev Team
- Join Date
- Mar 2007
- Location
- Haarlem, Netherlands
- Posts
- 1,235
- Vote Rating
- 4
This function is there as legacy code and is not used anywhere in our framework or examples. It's logic is indeed flawed it seems. The question is whether we want to return the "data index" of the record bound to the item, or the index of the item in the listItems array (which seems pointless info to me). So for now I have just updated the method to become like this for the next release:
Is this what you would expect the function to return as well?Code:/** * Returns an index for the specified item. * @param {Number} item The item to locate. * @return {Number} Index of the record bound to the specified item. */ getItemIndex: function(item) { return item.dataIndex; }
Best,
Tommy
-
6 Dec 2012 1:12 AM #5
Spot on
Spot on
Hello Tommy,
Yes, that's exactly what I'd expect and it's identical to my "overrides:" fix currently in use. Thanks!
Success! Looks like we've fixed this one. According to our records the fix was applied for
TOUCH-3756
in
Sprint 28.


Reply With Quote
