Looks like we can't reproduce the issue or there's a problem in the test case provided.
  1. #1
    Ext JS Premium Member canxss's Avatar
    Join Date
    Sep 2008
    Posts
    184
    Vote Rating
    3
    canxss is on a distinguished road

      0  

    Default Destroyed Ext.tree.View's event listeners on store aren't removed

    Destroyed Ext.tree.View's event listeners on store aren't removed


    Ext version tested:
    Ext 4.1.4.605


    Browser versions tested against:
    Chrome 24.0.1312.56 m
    Firefox 18.0.1


    Description:
    Destroyed Ext.tree.View is not removed from the TreeStore's event listeners. I have a window that has a treepanel. When I close and reopen the window the same TreeStore is reused and tried to be loaded. During store load beforefill event is called for the destroyed view and gives error.


    Steps to reproduce the problem:
    I've modified the treegrid.js example in order to place treepanel inside a window to reuse it. I've presented it as a test case.


    Test Case:

    Code:
    Ext.Loader.setConfig({
        enabled: true,
        disableCaching: false
    });Ext.Loader.setPath('Ext.ux', '../ux');
    
    
    Ext.require([
        'Ext.data.*',
        'Ext.grid.*',
        'Ext.tree.*',
        'Ext.ux.CheckColumn'
    ]);
    
    
    Ext.onReady(function() {
        Ext.QuickTips.init();
    
    
        //we want to setup a model and store instead of using dataUrl
        Ext.define('Task', {
            extend: 'Ext.data.Model',
            fields: [
                {name: 'task',     type: 'string'},
                {name: 'user',     type: 'string'},
                {name: 'duration', type: 'string'},
                {name: 'done',     type: 'boolean'}
            ]
        });
    
    
        var store = Ext.create('Ext.data.TreeStore', {
            model: 'Task',
            proxy: {
                type: 'ajax',
                //the store will get the content from the .json file
                url: 'treegrid.json'
            },
            folderSort: true
        });
    
    
        var button = Ext.create('Ext.Button', {
          renderTo: 'show-tree-button',
          text: 'Show Tree',
          handler: function() {
            var tree2 = Ext.create('Ext.tree.Panel', {
                title: 'Core Team Projects',
                width: 500,
                height: 300,
                collapsible: true,
                useArrows: true,
                rootVisible: false,
                store: store,
                multiSelect: true,
                singleExpand: true,
                //the 'columns' property is now 'headers'
                columns: [{
                    xtype: 'treecolumn', //this is so we know which column will show the tree
                    text: 'Task',
                    flex: 2,
                    sortable: true,
                    dataIndex: 'task'
                },{
                    //we must use the templateheader component so we can use a custom tpl
                    xtype: 'templatecolumn',
                    text: 'Duration',
                    flex: 1,
                    sortable: true,
                    dataIndex: 'duration',
                    align: 'center',
                    //add in the custom tpl for the rows
                    tpl: Ext.create('Ext.XTemplate', '{duration:this.formatHours}', {
                        formatHours: function(v) {
                            if (v < 1) {
                                return Math.round(v * 60) + ' mins';
                            } else if (Math.floor(v) !== v) {
                                var min = v - Math.floor(v);
                                return Math.floor(v) + 'h ' + Math.round(min * 60) + 'm';
                            } else {
                                return v + ' hour' + (v === 1 ? '' : 's');
                            }
                        }
                    })
                },{
                    text: 'Assigned To',
                    flex: 1,
                    dataIndex: 'user',
                    sortable: true
                }, {
                    xtype: 'checkcolumn',
                    header: 'Done',
                    dataIndex: 'done',
                    width: 40,
                    stopSelection: false
                }, {
                    text: 'Edit',
                    width: 40,
                    menuDisabled: true,
                    xtype: 'actioncolumn',
                    tooltip: 'Edit task',
                    align: 'center',
                    icon: '../simple-tasks/resources/images/edit_task.png',
                    handler: function(grid, rowIndex, colIndex, actionItem, event, record, row) {
                        Ext.Msg.alert('Editing' + (record.get('done') ? ' completed task' : '') , record.get('task'));
                    },
                    // Only leaf level tasks may be edited
                    isDisabled: function(view, rowIdx, colIdx, item, record) {
                        return !record.data.leaf;
                    }
                }]
            });
    
    
            var win = Ext.create('Ext.Window', {
              items: tree2,
              listeners: {
                'boxready': function() {
                  if (!store.isLoading())
                    store.load();
                },
                scope: this
              }
            });
    
    
            win.show();
          },
          scope: this
        });
    
    
    });
    I couldn't find a way to overcome this bug. So I'm hoping, until the bug is fixed in source code someone will present a temporary fix.

    Ipek

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


    Checking the hasListeners object in 4.2.0 beta 2 it looks like the listeners are removed properly.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Ext JS Premium Member canxss's Avatar
    Join Date
    Sep 2008
    Posts
    184
    Vote Rating
    3
    canxss is on a distinguished road

      0  

    Default


    Thanks for the reply.

    What should I do to overcome this bug while using Ext 4.1?

    ─░pek

Thread Participants: 1