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

      0  

    Default [2.0+] GridView's destroy method destroying uncreated elements

    [2.0+] GridView's destroy method destroying uncreated elements


    I have a GridView which is added as part of the UI before being reconfigured to accept a Store and ColumnModel. These are loaded from the server on demand.

    If the GridPanel is destroyed, it calls GridView.destroy.

    This method may attempt to destroy things which might not have been rendered. This was causing errors on our system when we navigated, or otherwise caused the empty GridPanel to be destroyed.

    In particular, the destroy method fiddles with the column drag/drop objects in quite a "coupled" way. It should not interfere with the internals of these classes. These classes should implement the Ext.dd.DD unreg method to do their own cleanup (and then call the superclass one).

    Any user of a DD class should just call unreg() and that should be it.

    So we need in ColumnDD.js:

    Code:
    Ext.override(Ext.grid.HeaderDropZone, {
        unreg: function() {
            this.proxyTop.remove();
            this.proxyBottom.remove();
            Ext.grid.HeaderDropZone.superclass.unreg.apply(this, arguments);
        }
    });
    And in GridView.js:

    Code:
    Ext.override(Ext.grid.GridView, {
        onColumnWidthUpdated : function(col, w, tw){      // not related, but
            this.focusEl.setWidth(this.getTotalWidth());  // the width should be honoured even when empty!!!
        },
    
        destroy : function(){
            if(this.colMenu){
                Ext.menu.MenuMgr.unregister(this.colMenu);
                this.colMenu.destroy();
                delete this.colMenu;
            }
            if(this.hmenu){
                Ext.menu.MenuMgr.unregister(this.hmenu);
                this.hmenu.destroy();
                delete this.hmenu;
            }
            if(this.grid.enableColumnMove){
                var elid, dds = Ext.dd.DDM.ids['gridHeader' + this.grid.getGridEl().id];
                if(dds){
                    for(var dd in dds){
                        if(!dds[dd].config.isTarget && (elid = dds[dd].dragElId)){
                            Ext.get(elid).remove();
                        }
                        if(Ext.dd.DDM.locationCache[dd]){
                            delete Ext.dd.DDM.locationCache[dd];
                        }
                        dds[dd].unreg();
                    }
                    delete Ext.dd.DDM.ids['gridHeader' + this.grid.getGridEl().id];
                }
            }
    
            if(this.dragZone){
                this.dragZone.unreg();
            }
            
            Ext.fly(this.innerHd).removeAllListeners();
            Ext.removeNode(this.innerHd);
            
            Ext.destroy(this.resizeMarker, this.resizeProxy, this.focusEl, this.mainBody, 
                        this.scroller, this.mainHd, this.mainWrap, this.dragZone, 
                        this.splitone, this.columnDrag, this.columnDrop);
    
            this.initData(null, null);
            Ext.EventManager.removeResizeListener(this.onWindowResize, this);
        }
    });

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

      0  

    Default


    Which leads to problems with the order of window unload handlers which Ext adds.

    By the time the DDManager's window unload handler runs (which calls unreg on all DD instances), Ext.Element's window unload handler has run (because Ext.Element wasd defined first, and so added the first listener)

    Ext.Element's unload handler is

    Code:
    Ext.EventManager.on(window, 'unload', function(){
        delete El.cache;
        delete El._flyweights;
    });
    Which causes problems in later-firing window unload handlers which attempt to remove their Elements. Element.cache is deleted, so Element.remove throws errors.

    Theer are several window unload handlers added throughout Ext.

    it would be better IMNSHO if there was one, unified Ext unload handler in EventManager.js

    This would run through the necessary unload processing. The functionality should be pulled in from all the other unload handlers, and done there in the correct order.

    Obviously testing presence of packages - only calling Ext.dd.DragDropMgr._onUnload if Ext.dd was present.

  3. #3
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,251
    Vote Rating
    73
    Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold

      0  

    Default


    Or you could create an onWindowUnload method (like onWindowResize is doing now, which by the way Ext.dd.DragDropMgr is also not using!).

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

      0  

    Default


    The reason why window resize is wrapped is to "throttle" its rate of firing so that resize handlers are not called for every pixel of movement. This is a different issue, unload only fires once, it's the order in which different classes add their unload handlers which is the problem.

    As well as the original coupling problem of GridView interfering in private members of HeaderDropZone which it should not know about, and which may not exist...

Thread Participants: 1

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar