PDA

View Full Version : ContentPanel advise: setUrl() vs updater.setDefaultUrl



seymores
20 Apr 2007, 6:46 AM
Hi all,

I have a question here which I need some advise.

I have a ContentPanel and to update that panel I used setUrl() then call refresh(). Then I read from somewhere in this forum that the right way is to use UpdateManager to set the defaultUrl then call refresh().

I tried both so far I can't see the advantage of using UpdateManager compared to using ContentPanel's setUrl(). Both needs to call refresh().

Anyone care to enlighten me on this? ~o)



var onRowClick = function(grid, rowIndex, e) {
var rowRecord = grid.getDataSource().getAt(rowIndex);
//Ext.MessageBox.confirm('Test', rowRecord.id);
//contentPane.setUrl('/Minutes/meetingMinute/view/' + rowRecord.id, false);
//contentPane.refresh();
contentPane.setTitle("Meeting minute details [" + rowRecord.id + "]");

var updater = contentPane.getUpdateManager();
updater.loadScripts = true;
updater.setDefaultUrl('/Minutes/meetingMinute/view/' + rowRecord.id);
updater.refresh();
}

20 Apr 2007, 7:20 AM
I would suggest doing an iframe and fitting that inside. When you do a seturl you're subject to what i call "CSS Bleed". Your URL will be loaded via XHR and any CSS Defs will muck up your site.

I added the following to my layout.js;
region = center/east/etc.
id = id of the iframe.
title = title of the tab.
url = source for the iframe.


...
addUpdateTab: function(region, id, title, url) {
center = layout.getRegion('center');
if (! layout.getRegion(region).hasPanel(id) ) {

layout.beginUpdate();
layout.add(region, new Ext.ContentPanel(id, {
autoCreate: true,
title: title,
closable: false,
fitToFrame: true
}));
Ext.get(id).dom.src = url;
layout.endUpdate();
}
else {
layout.beginUpdate();
Ext.get(id).dom.src = url;
layout.endUpdate();
}
...



<iframe id="myIFrame frameborder="no"></iframe>

tryanDLS
20 Apr 2007, 7:21 AM
ContentPanel.load calls UpdateManager under the covers, so it really doesn't matter. You can eliminate the ref to UpdateManager in your code by passing everything in the load config - if you want to streamline your code a little. There's an example of this in the doc of load. (http://extjs.com/deploy/ext/docs/output/Ext.ContentPanel.html#load)

seymores
20 Apr 2007, 4:21 PM
Thank you guys!
\:D/

Animal
20 Apr 2007, 9:55 PM
I don't understand the point about "CSS bleed".

Content loaded through the UpdateManager does not process CSS <style> elements.

From what jack has posted about this, it was a design decision. All CSS style rules for a page are expected to be loaded at page load time.