Success! Looks like we've fixed this one. According to our records the fix was applied for EXTJS-6627 in a recent build.
  1. #1
    Sencha User
    Join Date
    May 2009
    Posts
    135
    Vote Rating
    1
    DiscoBoy is on a distinguished road

      0  

    Default [ExtJS 4.1] Copying of models is broken in 4.1

    [ExtJS 4.1] Copying of models is broken in 4.1


    I was used to decorate my models in ExtJS 4.0 with additional data properties on the fly (Need this for tree nodes). When copying the decorated record a via b = a.copy() all of my decorations to a were also copied to b.

    In ExtJS 4.1 only the fields which are defined in the model a are getting copied! Is this change intended in 4.1 or a bug?

    An exmaple code to test (once with 4.0, then 4.1)

    Code:
    Ext.define('Test', {extend: 'Ext.data.Model', fields: ['property1']});
    
    a = Ext.create('Test', {property1: 'Teast A'});
    a.set('property2', 'My decoration');
    b = a.copy();
    
    console.log("A:", a.data);
    console.log("B:",b.data);
    See the difference? I really would like to know how I should make exact copies of my model records now. Help and suggestions appreciated!

  2. #2
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,506
    Vote Rating
    54
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    It's a bug!

    Test this override:

    Code:
    Ext.override(Ext.data.Model, {
        copy : function(newId) {
            var me = this;
    
            return new me.self(me.raw, newId, null, Ext.apply({}, me[me.persistenceProperty]));
        }
    });
    If that works for you, I'll open a ticket and get the fix in.

  3. #3
    Sencha User
    Join Date
    May 2009
    Posts
    135
    Vote Rating
    1
    DiscoBoy is on a distinguished road

      0  

    Default


    Yes, this works now! You can try it with my example above as well! Thx for fixing this, then I can remove my temprary workaround :-)

  4. #4
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,506
    Vote Rating
    54
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    It's slated for the 4.1.2 release.

Thread Participants: 1