Results 1 to 9 of 9

Thread: this.getRecord() in Ext.dataview.component.DataItem not working in RC1 and 2

    Success! Looks like we've fixed this one. According to our records the fix was applied for TOUCH-2362 in a recent build.
  1. #1
    Sencha User ilija139's Avatar
    Join Date
    Aug 2011
    Location
    Macedonia
    Posts
    36

    Default this.getRecord() in Ext.dataview.component.DataItem not working in RC1 and 2

    this.getRecord() sometimes returns wrong record in RC1 and RC2. It works properly in beta3. For example:

    Code:
      
    ....
    actionButton: {            cls     : 'action-button',
                docked  : 'left',
                iconCls : 'add',
                iconMask: true
            },
    ....
    
    
    
            control:{
                '.action-button': {
                    tap: 'onActionTap', element:'element'
                }
            },
    
    ...
    
    onActionTap:function(event, arg1, arg2, arg3, arg4) {
            console.log('onActionTap', this.getRecord());//this returns sometimes wrong record 
    }
    Is this a known bug? Let me know if I need to supply detailed test case.

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,379

    Default

    This sounds like a bug, if you have a test case I can report it.
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

    Posts are my own, not any current, past or future employer's.

  3. #3
    Sencha User
    Join Date
    Feb 2012
    Posts
    2

    Default

    I have run into this issue as well. I've run the same code that worked with beta3 again with RC2...and the RC2 does not send the correct record to the DataItem. What kind of test case do you need? Just an example that works in beta3 and doesn't in RC2? Thanks very much for the help!

  4. #4
    Sencha User ilija139's Avatar
    Join Date
    Aug 2011
    Location
    Macedonia
    Posts
    36

    Default

    I've find out that the bug happens after you apply filters to the store that is linked to the dataview. I have attached working code to reproduce the bug.

    Ext version tested:
    • Sencha Touch 2.0RC1
    • Sencha Touch 2.0RC2
    Browser versions tested against:
    • Chrome 18 (Mac OS X)
    Description:
    • this.getRecord() inside dataitem doesn't return the correct record when the ordering of the records is altered, e.g. filters being applied to the dataview's store.
    Test Case:

    Code:
    //this is a function that gets called when one of the component gets tapped.
        onActionTap:function() {
            //The store associated with this dataview.
            var store = Ext.getStore('Users');
            store.clearFilter();
            //Bug happens when we apply filters.
            store.filter('number', 3);
            console.log('onActionTap', this.getRecord().get('name'));
        },
    Attached Files Attached Files

  5. #5
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,379

    Default

    In that example, I tap a button and it filters and goes down to one row and console.log's out the name of the player I tapped on. So far so good. I tap on the button of the single row that is left and I get 'Player1' not 'Player3', is this the bug you are talking about?
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

    Posts are my own, not any current, past or future employer's.

  6. #6
    Sencha User ilija139's Avatar
    Join Date
    Aug 2011
    Location
    Macedonia
    Posts
    36

    Default

    Exactly.

  7. #7
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,379

    Default

    Ok. I have opened a bug report up.
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

    Posts are my own, not any current, past or future employer's.

  8. #8
    Sencha User Jamie Avins's Avatar
    Join Date
    Mar 2007
    Location
    Redwood City, California
    Posts
    3,661

    Default

    This has been fixed for the next release. You should be able to use this override:

    Code:
    Ext.define('Ext.overrides.DataItem',
        override: 'Ext.dataview.DataItem',
    
        updateRecord: function(newRecord) {
            if (!newRecord) {
                return;
            }
            this._record = newRecord;
    
            var me = this,
                dataview = me.config.dataview,
                data = dataview.prepareData(newRecord.getData(true), dataview.getStore().indexOf(newRecord), newRecord),
                items = me.getItems(),
                item = items.first(),
                dataMap = me.getDataMap(),
                componentName, component, setterMap, setterName;
    
            if (!item) {
                return;
            }
            for (componentName in dataMap) {
                setterMap = dataMap[componentName];
                component = me[componentName]();
                if (component) {
                    for (setterName in setterMap) {
                        if (component[setterName]) {
                            component[setterName](data[setterMap[setterName]]);
                        }
                    }
                }
            }
    
            /**
             * @event updatedata
             * Fires whenever the data of the DataItem is updated
             * @param {Ext.dataview.component.DataItem} this The DataItem instance
             * @param {Object} newData The new data
             */
            me.fireEvent('updatedata', me, data);
    
            // Bypassing setter because sometimes we pass the same object (different properties)
            item.updateData(data);
        }
    });

    Sencha Inc

    Jamie Avins

    @jamieavins

  9. #9
    Sencha User ilija139's Avatar
    Join Date
    Aug 2011
    Location
    Macedonia
    Posts
    36

    Default

    That was quick. 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
  •