Results 1 to 7 of 7

Thread: Compatibility mode breaks TreeStore

    You found a bug! We've classified it as EXTJS-14927 . We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
  1. #1
    Sencha Premium Member
    Join Date
    Aug 2013
    Posts
    21

    Default Compatibility mode breaks TreeStore

    If you set the compatibility mode to 4.2 in your app.json, you get an error when trying to remove items from a tree store. This looks to be a problem with the old version of Model.unjoin conflicting with the fact that TreeStore now extends from Store. You should be able to reproduce this by running the following code inside an application set to 4.2 compatibility.




    Code:
     Ext.define('User', {
         extend: 'Ext.data.Model',
         fields: [
             {name: 'firstName', type: 'string'},
             {name: 'lastName',  type: 'string'}
         ]
     });
    
    
     var myStore = Ext.create('Ext.data.TreeStore', {
         model: 'User',
         proxy: "memory",
         autoLoad: true
     });
    
    
    var user = Ext.create("User", {
        firstName: "my",
        lastName: "name",
    })
    
    
    myStore.add(user);
    console.log(myStore.getRange());
    myStore.removeAll();
    console.log(myStore.getRange());



    You should see the following trace when removeAll is called:
    Code:
    Uncaught TypeError: Cannot read property 'length' of undefined Model.js:2161
    Ext.define.deprecated.methods.unjoinModel.js:2161
    Ext.define.onCollectionRemoveStore.js:721
    Ext.define.notifyCollection.js:2920
    Ext.define.spliceCollection.js:2068
    Ext.define.removeAtCollection.js:1768
    Ext.define.removeAtStore.js:771
    Ext.define.onNodeCollapseTreeStore.js:648
    Ext.define.onNodeSortTreeStore.js:945
    callTreeStoreNodeInterface.js:1849
    sortNodeInterface.js:1455
    Ext.define.onSorterEndUpdateTreeStore.js:260
    Ext.define.doFire

  2. #2
    Sencha Premium Member
    Join Date
    Nov 2007
    Location
    Sydney
    Posts
    117

    Default

    I can confirm that we are running into the same problem.

  3. #3
    Sencha Premium Member
    Join Date
    Aug 2013
    Posts
    21

    Default

    As an aside, does anyone know if it's possible to set compatibility mode on in a Sencha fiddle?

  4. #4
    Sencha User slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    6,165

    Default

    Thank you for the report!
    *It is not possible to set the build compatibility mode in Fiddle.

  5. #5
    Sencha User
    Join Date
    Mar 2016
    Posts
    97

    Default

    This problem still appears in 6.0.1.250, was there any workaround for this?

  6. #6

    Default Workaround?

    Do we have any workaround for the time being? I need this fix badly

    Using ExtJs 5.1

  7. #7
    Sencha Premium User
    Join Date
    May 2014
    Posts
    5

    Default Bug Fix - Solution

    The problem is with the way the deprecated unjoin method is being invoked.
    In order to overcome, we just need to override the unjoin method of the Ext.data.Model class to fix the issue.
    Try the below override, you should have no more issues with any reload of the treeStore or any operation which involves the removing of the TreeStore elements.


    Code:
    Ext.override(Ext.data.Model, {
         unjoin: function (item) {
            var me = this,
                joined = me.joined,            
                
                // TreeModels are never joined to their TreeStore.
                // But unjoin is called by the base class's onCollectionRemove, so joined may be undefined.
                len = joined && joined.length,
                store = me.store,
                i;
    
    
            if (len === 1 && joined[0] === item) {
                joined.length = 0;
            } else if (len) {
                Ext.Array.remove(joined, item);
            }
    
    
            if (store === item) {
                store = null;
                if (joined) {
                    for (i = 0, len = joined.length; i < len; ++i) {
                        item = joined[i];
                        if (item.isStore) {
                            store = item;
                            break;
                        }
                    }
                }
                me.store = store;
            }
        }
    });

Posting Permissions

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