View Full Version : refresh hyml in panel?

16 Aug 2011, 7:03 AM
I have a panel with some html in it. Something like this:

var activity = new Ext.Panel(
floating: true,
modal: true,
centered: true,
html: 'Msg:' + sMessage

It displays the panel fine with the content of the var sMessage.
But whenever i change the content of sMessage into something else, then it still displays the old sMessage value.

I know i can fully update the html with the update() method. But that means i have to rewrite everything that is inside the html: property.... In my real app i have alot of html instead of just 'Msg: ', So that would be troublesome to rewrite...

So i was wondering if there's a method to reload the entire Panel, so that it also takes the new value of sMessage..??

16 Aug 2011, 12:57 PM
did you try a doLayout() on the panel?

16 Aug 2011, 2:16 PM
I do not think a doLayout() will work since activity panel is declared once and for all
And Panel.html is deleted in initContent()

Now I do not really understand what you really want to do.
You may have to store your sMessage in a more global variable (or as a Panel custom property) and call a method to change it and then update() panel.
But if html is a big string, it is really not optimized !

16 Aug 2011, 7:04 PM
You may want to try an XTemplate.

var myPanel = new Ext.Panel({
floating: true,
modal: true,
tpl: '{myHtml}',
id: 'idOfMyPanel'

function populatePanel(htmlYouWant){
var dataObject = {myHtml: htmlYouWant};

Basically the XTemplate will use the data object you create using the same member name. If you are confused look at the video on XTemplates. Really useful.