Success! Looks like we've fixed this one. According to our records the fix was applied for TOUCH-4108 in a recent build.
  1. #1
    Sencha - Ext JS Dev Team
    Join Date
    Jul 2012
    Posts
    25
    Vote Rating
    0
    vitalyx is on a distinguished road

      0  

    Default Property updater is not being called because of invalid value !== oldValue check

    Property updater is not being called because of invalid value !== oldValue check


    Sencha Touch 2.1 today's nightly (touch-2.1-20130310), but also present in the 2.1.1.Tested in Chrome 25.0.1364.160 m

    This is a MAJOR issue where updater isn't called, even though it is defined and newValue is not equal to the oldValue, because the newValue !== oldValue check is broken.

    The error happens in the Class.js's method generateSetter:

    Code:
            generateSetter: function(nameMap) {
                var internalName = nameMap.internal,
                    getName = nameMap.get,
                    applyName = nameMap.apply,
                    updateName = nameMap.update,
                    setter;
    
                setter = function(value) {
                    var oldValue = this[internalName],
                        applier = this[applyName],
                        updater = this[updateName];
    
                    delete this[getName];
    
                    if (applier) {
                        value = applier.call(this, value, oldValue);
                    }
    
                    if (typeof value != 'undefined') {
                        this[internalName] = value;
    
                        if (updater && value !== oldValue) {
                            updater.call(this, value, oldValue);
                        }
                    }
    
                    return this;
                };
    
                setter.$isDefault = true;
    
                return setter;
            },
    For example
    Code:
             store.setGrouper({
                property: 'component',
                sortProperty: 'order'
            })
    doesn't work because of this bug (the updateGrouper method of the store is not called). And I would imagine the whole bunch of other things could be broken too.


    Test Case

    Code:
    Ext.define('MyModel', {
        extend : 'Ext.data.Model',
        config : {
            fields : ['foo', 'group1', 'group2']
        }
    });
    
    Ext.Viewport.add({
        xtype   : 'list',
        itemTpl : '{foo}',
        grouped : true,
        store   : {
            model   : 'MyModel',
            grouper : {
                property     : 'group1',
                sortProperty : 'group1'
            },
            data    : [
                { foo : 'One',   group1 : 'Number', group2 : 'Integer' },
                { foo : 'A',     group1 : 'Text',   group2 : 'String'  },
                { foo : 'Two',   group1 : 'Number', group2 : 'Integer' },
                { foo : 'Three', group1 : 'Number', group2 : 'Integer' },
                { foo : 'B',     group1 : 'Text',   group2 : 'String'  }
            ]
        },
        items   : [
            {
                xtype  : 'toolbar',
                docked : 'top',
                items  : [
                    {
                        text    : 'Set group1',
                        handler : function (button) {
                            var list  = button.up('list'),
                                store = list.getStore();
    
                            store.setGrouper({
                                property     : 'group1',
                                sortProperty : 'group1'
                            });
                        }
                    },
                    {
                        text    : 'Set group2',
                        handler : function (button) {
                            var list  = button.up('list'),
                                store = list.getStore();
    
                            store.setGrouper({
                                property     : 'group2',
                                sortProperty : 'group2'
                            });
                        }
                    }
                ]
            }
        ]
    });
    Last edited by mitchellsimoens; 11 Mar 2013 at 6:58 AM. Reason: added test

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,811
    Vote Rating
    834
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


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

  3. #3
    Sencha User
    Join Date
    Mar 2007
    Location
    Haarlem, Netherlands
    Posts
    1,243
    Vote Rating
    10
    TommyMaintz will become famous soon enough TommyMaintz will become famous soon enough

      0  

    Default


    This issue has been fixed specifically for groupers. The reason the updater is not called is because the Ext.factory method was changing the current grouper instance and thus the value isnt actually updated. This is not a bug and is something that our code should have worked around.

    Anyway, this issue will be fixed in 2.2.1. Thanks for the report.

Thread Participants: 2