PDA

View Full Version : How to refresh ContentPanel from inside an iframe of another one?



Topper
17 Aug 2007, 5:01 AM
Hello. I have a nested layout like



<div id="north-div" class="header"></div>
<div id="east-div"></div>
<div id="west-div"></div>
<div id="center-div">
<iframe id="center-iframe" frameborder="0" scrolling="auto" style="border:0px none;"></iframe>
</div>


I need to trigger a refresh() of the east-div content when a function inside the center iframe does something.

Any clues? I tried to use DomQuery but cant cast the html element to ContentPanel :/

Thx in advance

Neo
18 Aug 2007, 12:38 AM
Hi Topper

I had a similar problem this week so I finally posted a small guide to solve this situation with iframes:

http://extjs.com/forum/showthread.php?t=11110&highlight=iframe

please let me know if you find it useful. I you find out something interesting tell me so and I will edit the post to include some new useful information so the next ones to have the same problem would solve it easily.

Good luck!! Neo.

Topper
19 Aug 2007, 5:04 AM
Sory for the delay.

I alredy got it working. The only thing I needed was to refresh the east content panel when the iframe data displayed changed. I added this lines inside the datastore on load event of the iframe's grid. I found 2 ways to get it working and here are both:

1st way:



var eastDiv = parent.document.getElementById('east-div');
var extEastDiv = Ext.get(eastDiv);
var updater = extEastDiv.getUpdateManager();
updater.defaultUrl = '../jsp/estadisticas.jsp';
updater.refresh();

and the 2nd:



var eastDiv = parent.document.getElementById('east-div');
var extEastDiv = Ext.get(eastDiv);
var updater = extEastDiv.getUpdateManager();
updater.update({url:"../jsp/estadisticas.jsp"});


(I dunno wich one is better).

I dont know if this approach is ok or if exists a better one (please let me know in that case).

Thx a lot
Topper

Neo
19 Aug 2007, 10:46 PM
The documentation says:

REFRESH
Refresh the element with the last used url or defaultUrl. If there is no url, it returns immediately

UPDATE
Performs an async request, updating this element with the response. If params are specified it uses POST, otherwise it uses GET.

so I guess it depends on what you need.