Results 1 to 3 of 3

Thread: Fixed: TreeGrid reconfigure store error.

  1. #1
    Sencha User murrah's Avatar
    Join Date
    Oct 2007
    Location
    Katoomba, Blue Mountains, west of Sydney, Australia
    Posts
    400

    Default Fixed: TreeGrid reconfigure store error.

    Hi.
    This looks like a bug and this is my fix so I am posting it here. It might not be the correct way, but it is working well for me.

    Symptom:
    Calling myTree.reconfigure(myStore) causes error message store.indexOf is not a function in Ext.data.Model.refresh()

    Explanation:
    I am using Ext.tree.Panel, Ext.data.TreeStore and TreeGrid (ie one of the columns is xtype 'treecolumn').

    When the tree instantiates, it detects the treecolumn and uses injectLockable() to split the tree grid into two grids - one is tree.lockedGrid (with a store of class Ext.data.TreeStore) and the other is tree.normalGrid (with a store of class Ext.data.NodeStore).

    However, when you call myTree.reconfigure(myStore), passing a new instance of Ext.data.TreeStore, the Ext.grid.locking.Lockable.reconfigureLockable() method binds the new TreeStore to both the lockGrid and the normalGrid. the normalGrid is expecting a Ext.data.NodeStore which has an indexOf() method, but instead gets an Ext.data.TreeStore which doesnt have an indexOf() method, and so the error arises when the model refreshes.

    My fix is to override Ext.grid.locking.Lockable.reconfigureLockable() method to bind the correct store. This has solved the problem and I can now dynamically add a new store to the TreeGrid instance.
    PHP Code:
    /**
     * Override to enable reconfigure() method of TreeGrid instance.
     * See comments below for the change,.
     */
    Ext.define('Ext.overrides.grid.locking.Lockable', {
        
    override'Ext.grid.locking.Lockable',

        
    reconfigureLockable: function(storecolumns) {
            var 
    me this,
                
    oldStore me.store,
                
    lockedGrid me.lockedGrid,
                
    normalGrid me.normalGrid;

            
    Ext.suspendLayouts();
            if (
    columns) {
                
    lockedGrid.headerCt.removeAll();
                
    normalGrid.headerCt.removeAll();

                
    columns me.processColumns(columns);

                
    // Flag to the locked column add listener to do nothing
                
    me.ignoreAddLockedColumn true;
                
    lockedGrid.headerCt.add(columns.locked.items);
                
    me.ignoreAddLockedColumn false;
                
    normalGrid.headerCt.add(columns.normal.items);

                
    // Ensure locked grid is set up correctly with correct width and bottom border,
                // and that both grids' visibility and scrollability status is correct
                
    me.syncLockedWidth();
            }

            if (
    store && store !== oldStore) {
                
    store Ext.data.StoreManager.lookup(store);
                
    me.store store;
                
    lockedGrid.bindStore(store);

                
    // ============ Start change
                
                                // removed this line
                //normalGrid.bindStore(store); 

                                // Added this instead to replicate what happens in me.injectLockable()
                                // That is, we end up with a normalGrid.store that is an Ext.data.NodeStore 
                                // rather than an Ext.data.TreeStore ( which is the xtype of the store passed
                                // into this reconfigureLockable method )
                
    if (me.isTree) {
                    
    normalGrid.bindStore(lockedGrid.view.store);
                }
                
    // ============ End changes:
                
            
    } else {
                
    lockedGrid.getView().refresh();
                
    normalGrid.getView().refresh();
            }
            
    Ext.resumeLayouts(true);
        }
     
    }); 
    Example of use:
    PHP Code:
    var sMyTreeStore Ext.create('App.store.sMyTreeStore');

                    
    // Reconfigure the tree store. Creates a lockedGrid and a normalGrid, each
                    // with their own stores (but they are linked so they are in sync)
    vMyTree.reconfigure(sMyTreeStore); 
    Cheers,
    Murray

  2. #2
    Sencha User
    Join Date
    Feb 2013
    Location
    California
    Posts
    11,985

    Default

    Thanks for sharing this override with the community! With which version of ExtJS is it designed to work? Any chance you have a test case lying around which recreates this issue so we can file a bug?

  3. #3
    Sencha User murrah's Avatar
    Join Date
    Oct 2007
    Location
    Katoomba, Blue Mountains, west of Sydney, Australia
    Posts
    400

    Default

    Yep. Unzip attached into Ext /examples folder.
    Ext 4.2

    Thanks!
    Attached Files Attached Files

Tags for this Thread

Posting Permissions

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