Results 1 to 5 of 5

Thread: Bug in the 2.1 list implementation

    Success! Looks like we've fixed this one. According to our records the fix was applied for TOUCH-3756 in a recent build.
  1. #1
    Sencha User
    Join Date
    Feb 2012
    Posts
    26
    Vote Rating
    1
      0  

    Default 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
    Code:
    getItemIndex: function(item) {
        var index = item.dataIndex;
        return (index === -1) ? index : this.indexOffset + index;    
    },
    
    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.

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,556
    Vote Rating
    1272
      0  

    Default

    Thanks for the report! I have opened a bug in our bug tracker.

  3. #3
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,556
    Vote Rating
    1272
      0  

    Default

    I used the list example and scrolled down to the D group and did this:

    Code:
    var list = Ext.ComponentQuery.query('list')[0],
        idx  = list.getStore().indexOf(list.listItems[0].getRecord());
    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.getItemIndex(list.listItems[0]);
    and it gave me 72.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  4. #4
    Sencha User
    Join Date
    Mar 2007
    Location
    Haarlem, Netherlands
    Posts
    1,243
    Vote Rating
    11
      0  

    Default

    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:

    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;
        }
    Is this what you would expect the function to return as well?

    Best,
    Tommy

  5. #5
    Sencha User
    Join Date
    Feb 2012
    Posts
    26
    Vote Rating
    1
      0  

    Default Spot on

    Hello Tommy,

    Yes, that's exactly what I'd expect and it's identical to my "overrides:" fix currently in use. Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •