tags:

views:

135

answers:

1

Hi, everyone

For some reason Ext.Panel.getTopToolbar() is returning an array of objects (the elements of the toolbar, but NOT the toolbar itself) and not an Ext.Toolbar. Because of that, I can't manage to hide an already set toolbar. How should I proceed?

Sample code:

function (panel)
{
    alert(panel.getTopToolbar()); // displays the list of elements in the toolbar
    panel.getTopToolbar().hide(); // error: "hide" is not a function
}
A: 

It should work, so it sounds like maybe you used topToolbar as a config instead of using tbar as the config? If you set a tbar config it gets instantiated and saved as topToolbar which is the Ext.Toolbar instance exposed by getTopToolbar(). If you overwrote topToolbar directly you might see this issue.

You might find this block of code in Panel.onRender (you'll have to include that file directly) and set a breakpoint in Firebug to see what's happening:

    if(this.tbar && this.topToolbar){
        if(this.topToolbar instanceof Array){
            this.topToolbar = new Ext.Toolbar(this.topToolbar);
        }
        this.topToolbar.render(this.tbar);
    }
bmoeskau
Not really. I've set tbar when instantiating the Exp.Panel. You mean what's happening could be explained if panel.topToolbar was set to an array?
n2liquid
You need to use Firebug and figure out what panel.getTopToolbar() is actually returning. There's no way for me to guess. By default, your code should be working so something must be happening outside of what you posted.
bmoeskau