PDA

View Full Version : Updating panel wirh toolbar



mschering
11 May 2007, 4:14 AM
How do I update the panel content without loosing the toolbar?

I have a ContentPanel with a toolbar in it. Also passed to the panel config {toolbar: tb}


<div id="panel"><div id="toolbar" /></div>

Now if I do a panel.load({url: 'somepage.php'});

The toolbar is lost. Is there any way to update it without loosing that toolbar?

jsakalos
11 May 2007, 5:36 AM
Try to remove your toolbar from panel's container.



<div id="panel" />
<div id="toolbar" />

mschering
11 May 2007, 6:35 AM
Thanks, but I already tried that. Didn't work. I don't remember exactly but either the toolbar wouldn't render at all if I put it outside or the toolbar still disappeared..

jsakalos
11 May 2007, 6:45 AM
What I really do is:



var dh = Ext.DomHelper;

if(!this.toolbar) {
this.toolbar = new Ext.Toolbar(dh.append(this.getEl(), {tag:'div',cls:this.tbClass}, true));
}

// create body
if(!this.body) {
this.body = dh.append(this.getEl(), {tag:'div',cls:this.bodyClass}, true)
this.resizeEl = this.body;
}

This code runs as a part of my extension of ContentPanel and creates toolbar and body at runtime. You do not need to create 'em in runtime but you can adjust your html markup based on this.

This works for sure.

mschering
11 May 2007, 6:49 AM
ok thanks I will try that.

But wouldn't it be good functionality in ext if you have the option to leave the toolbar alone in a contentpanel when you update it?

jsakalos
11 May 2007, 6:54 AM
Maybe, but you're asking the wrong guy ;) I'm just an Ext user as you are....

haibijon
11 May 2007, 7:16 AM
<div id="panel"><div id="panel-toolbar" /><div id="panel-body" /></div>



panel = new Ext.ContentPanel('west', {
toolbar: myToolbar,
resizeEl: 'panel-body',
autoScroll: true,
fitToFrame: true
});


Then instead of updating the panel, update the panel-body like so:



Ext.fly('panel-body').load({url: 'somepage.php'});

That should do the trick :D

mschering
11 May 2007, 8:15 AM
I actually tried it with Ext.get('divid') and that didn't work. Ext couldn't find the element. Maybe the fly function will. I'll give it a try thanks.

haibijon
11 May 2007, 8:36 AM
If Ext.get can't find the element then it's not in the DOM, or the DOM is malformed. Are you actually outputing xml shorthand tags like <div /> ? If so you shouldn't the browser won't handle it correctly, especially IE. You may want to try outputing the full closed tag <div id="someid" ></div>