toolbar.items.length

  • Hi, a plain question:
    Can I look at it, that in the toolbar there are elements?
    Can I delete an element, that it items.length too let him change?

    var toolbar = new Ext.Toolbar([
    { text: 1, handler: function() { this.destroy(); alert(toolbar.items.length); } },
    { text: 2, handler: function() { this.destroy(); alert(toolbar.items.length); } },
    { text: 3, handler: function() { this.destroy(); alert(toolbar.items.length); } }
    ]);

    new Ext.Panel({
    tbar: toolbar,
    renderTo: Ext.getBody()
    }); alert(3); alert(3); alert(3); I say thank you for it,
    Gabor


  • toolbar.remove is undefined... :(

    I need it only, that is it empty? this was finally:

    Ext.override(Ext.Toolbar, {
    isEmpty: function() {
    return this.tr.childNodes.length == 0;
    }
    });


  • That should be:

    toolbar.add(button);
    ...
    toolbar.remove(button);

    (autoDestroy is true by default, so the button gets destroyed when removed)


  • Ohhh... interesting.

    This is not good unfortunately.
    I add a button, then doLayout. Okay.
    I remove the button. Okay.
    DoLayout is newer then. Again there the button.

    var button = new Ext.Toolbar.Button({text:'hello'});
    var toolbar = new Ext.Toolbar();

    new Ext.Panel({
    tbar: toolbar,
    renderTo: Ext.getBody()
    });

    alert('.');

    toolbar.addButton(button);
    if(toolbar.doLayout) toolbar.doLayout();

    alert('.');

    button.destroy();

    alert('.');

    if(toolbar.doLayout) toolbar.doLayout();


  • The problem is that Toolbar isn't a proper Container, and stuff like updating items when a Component is removed aren't implemented.

    You could try Animal's Container Toolbar (http://extjs.com/forum/showthread.php?p=124322#post124322) class instead (already part of the Ext 3.0 trunk).







  • #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 toolbar.items.length , Please add it free.