Success! Looks like we've fixed this one. According to our records the fix was applied for EXTJS-7410 in a recent build.
  1. #1
    Ext JS Premium Member
    Join Date
    Nov 2007
    Location
    Cologne, Germany
    Posts
    13
    Vote Rating
    7
    stefan.lotties is on a distinguished road

      1  

    Default [4.1.2a] Ext.tree.View.onFillComplete uses too many records

    [4.1.2a] Ext.tree.View.onFillComplete uses too many records


    Hi,

    I reload tree nodes using Ext.tree.TreeStore.load({ node: ... }). This seems to be buggy when the node was a leaf and suddenly receives children (which might happen).

    In this case Ext.tree.View.onFillComplete is called which determines the nodes to reload. When the reloaded node has a sibling it duplicates and breaks the store.

    See this example:
    Code:
    <!DOCTYPE html>
    <html>
    	<head>
    		<script type="text/javascript" src="ext-all.js"></script>
    		<link rel="stylesheet" href="resources/css/ext-all.css"/>	
    		
    		<script type="text/javascript">
    Ext.define('Test.MockProxy', {
    	extend: 'Ext.data.proxy.Memory',
    	alias: 'proxy.mock',
    	
    	showChildren: false,
    	
    	read: function() {
    		if (this.showChildren) {
    			this.data = {
    				children: [
    					{ id: 'ChildOfA', text: 'Child of A' }					
    				]
    			};
    		} else {
    			this.data = [];
    		}
    		this.callParent(arguments);		
    	}
    });
    
    			
    Ext.onReady(function() {
    	var tree = Ext.create('Ext.tree.Panel', {
    		store: Ext.create('Ext.data.TreeStore', {
    			proxy: {
    				type: 'mock'
    			}
    		}),
    		root: {
    			id: 'root',
    			text: 'Root',
    			children: [
    				{ id: 'A', text: 'A' },
    				{ id: 'B', text: 'B' }
    			]
    		},
    		height: 700
    	});
    	
    	Ext.create('Ext.container.Container', {
    		renderTo: Ext.getBody(),
    		items: [
    			{
    				xtype: 'button',
    				toggleGroup: 'test',
    				toggleHandler: function(btn, pressed) {
    					tree.store.getProxy().showChildren = !tree.store.getProxy().showChildren;
    					
    					var a = tree.store.getById('A');
    					tree.store.load({
    						operation: 'read',
    						node: a,
    						callback: function(r, o) {
    							a.expand();
    						}
    					});
    				},
    				text: 'Show/hide childs of A'
    			},
    			tree
    		]
    	});
    });
    		</script>
    	</head>
    	<body>
    	</body>
    </html>
    This example provokes the behaviour. Usually A has no children but when pressing the button it'll receive one children which duplicates B.

    My (spontanous) solution was this:
    Code:
    Ext.define('Fixes.Ext.tree.View', {
    	override: 'Ext.tree.View',
    	
        onFillComplete: function(treeStore, fillRoot, newNodes){
            var me = this,
                store = me.store,
                start = me.fillRootIndex + 1,
                sibling = me.fillSibling,
                end, records;
    
            store.resumeEvents();
            delete me.fillSibling;
            delete me.fillRootIndex;
            
            // In the cases of expand, the records might not be in the store yet,
            // so jump out early and expand will handle it later
            if (!newNodes.length || store.indexOf(newNodes[0]) === -1) {
                return;
            }
                
            if (sibling) {
                // FIX: don't include the sibling
                end = store.indexOf(sibling) - 1;
                // /FIX
            }
    
            records = store.getRange(start, end);
            me.onAdd(store, records, start);
            fillRoot.triggerUIUpdate();
        }
    });
    Regards,
    Stefan

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,327
    Vote Rating
    849
    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


    We can look into this. I have opened a bug in our bug tracker.

  3. #3
    Touch Premium Member
    Join Date
    Feb 2011
    Location
    NJ
    Posts
    311
    Vote Rating
    52
    droessner is a jewel in the rough droessner is a jewel in the rough droessner is a jewel in the rough

      0  

    Default


    Stefan,

    Thank you very much for providing the override. I found this same bug yesterday, but have not heard back from Sencha Support about it yet. I'll have to do some more testing, but it seems that your override fixes the issue.

    Thanks again!
    Danny

  4. #4
    Sencha Premium Member
    Join Date
    Sep 2013
    Posts
    1
    Vote Rating
    0
    himanshu787 is on a distinguished road

      0  

    Default


    Is this still a bug or got fixed?