PDA

View Full Version : using refresh()



waylund
23 Feb 2009, 11:18 AM
I'm having some trouble with a refresh. I have this panel:

controlsPanel = new Ext.Panel({
region: 'west',
tbar: [{text: 'Advanced Add Task', listeners: {click: showAdvAddTaskWindow}}],
title: 'Controls',
width: 215,
collapsible: true,
autoScroll: true,
collapsed: true,
autoLoad: {url: 'ajax_listAllTasks.aspx', params: 'location=1&userID='+userID}
});

which loads fine. However, if I do controlsPanel.getUpdater().refresh() it it doesn't pass the parameters.

I tested running

controlsPanel.getUpdater().startAutoRefresh(1,'ajax_listAllTasks.aspx','location=1&userID='+userID);

in the chrome Javascript console and it works, but there is a long list of reasons why that isn't ideal. Is there a good way to refresh that page with the params getting passed properly?

for the record, I'm using it this way so that I can use post instead of putting the variables in the url.

arthurakay
23 Feb 2009, 3:14 PM
First of all, you should get in the habit of posting your code in the CODE or PHP tags... it's just easier to read :D

On to your question... you should probably be using controlsPanel.getUpdater().update(...) instead of .refresh().

I'll be honest and say I've never actually used the update method, but take a look at the API docs for Ext.Panel (http://extjs.com/deploy/dev/docs/?class=Ext.Panel). The 'autoLoad' config option calls an Ext.Updater.update() method. The 'update' method calls use POST by default when you use "params", so the URL that refresh() calls doesn't see those params.

Try giving that a shot.

waylund
24 Feb 2009, 9:48 AM
Thanks. I tried that in one case where the parameter is always the same and that worked great. I do have some cases where the params may be unknown. I notice I can't reference variables as myPanel.param or myPanel.url. I have a feeling I'm just not calling it right though. Is there some other way I should be getting that info?

arthurakay
24 Feb 2009, 10:19 AM
If I were you, I'd try writing your code like this so that you have easier access to your variables:



var myUpdateParams = {
url: 'ajax_listAllTasks.aspx',
params: {
location: 1,
userId: userId
}
};

controlsPanel = new Ext.Panel({
region: 'west',
tbar: [{text: 'Advanced Add Task', listeners: {click: showAdvAddTaskWindow}}],
title: 'Controls',
width: 215,
collapsible: true,
autoScroll: true,
collapsed: true,
autoLoad: myUpdateParams
});


Thus, you should be able to do myUpdateParams.params.userId

Give that a shot.

waylund
24 Feb 2009, 2:01 PM
Thanks, I didn't even think about that. That worked great.