Array help

  • Hi,
    In my application, I use an array o windows.
    I have a menu, every entry of it pointing to a function that opens a window with a specified ID.
    Ex:
    If the arWin["appUsers"] exists, only show the window, otherwise I create it and assign the object to arWin["appUsers"].

    Problem:
    When I close a window, how can I remove it from the array?
    I tried with

    arWin[this.mWinName].on("destroy", function(pEl){
    // the uncommented lines are what I tried
    // the commented are the ones that I'm using now ..
    // ( I hide the window, instead of closing it ... )

    // pEl.hide();
    // return false;

    arWin.remove(arWin[this.mWinName]);
    return true;
    });

    but seems like after destroy, the object is still there.
    I know in JavaScript the arrays have special behavior;
    Second, the object is referenced by the array and here can be a problem ..
    Please help me.


  • Dont use Array. Use Ext.WindowMgr to manage your windows. This will solve your problem.


  • Excellent point. I modified and works great.
    I tried before, but now I saw why it didn't work.
    In the desktop example, when creates windows, a new window manager is generated, instead of using the default global one.
    But now I modified this, and hope that nothing else will crash :s

    Anyway, my problem is more complicated. In every window, I have tabs, in every tab editable grids, for which, guess what : I use arrays !!!
    Here I got the same problem; for the moment, I'm canceling the destroy event for grids.
    On the interface appears like the window + grids are closing, but in fact only the window does ...

    Thank you very much for your suggestion!


  • Since I got some rendering (I presume..) errors with my grids when the window was loaded for the second time, I recreate them, even they exist.

    Situation: I have an array of grids arGrid indexed by the gridname.
    When re-open a window, I recreate all the grids in the window, assigning them to the arGrid[...].

    Question: Will this lead me to memory leaks problems?
    If I have arGrid["grid1"] = {Object} and I do arGrid["grid1"] = new Ext.EditorGridPanel (...)
    the old object is replaced in the array, but is it destroyed (since is not referenced anymore) ?

    Thanks







  • #If you have any other info about this subject , Please add it free.#
    Your name:
    E-mail:
    Telphone:

    Your comments:


    If you have any other info about Array help , Please add it free.

    7 January 2009 | cameltoepants.com | edit