PDA

View Full Version : Is Viewport Really State Aware



stumpy_uk
26 Nov 2007, 6:21 AM
I have read over 100 posts on here regarding the Viewport and its Stateevents etc but still cannot find a way of restoring state using the latest Beta, has anyone actually got the Staterestore to workwith a viewport. I have no problems with accordian etc and have cookies being written as part of the State Manager but all calls for restorestates do nothing and the viewport is returned to its original setup design.

Any help appreciated as this one is driving me insane...

Cheers

Stumpy.

hendricd
26 Nov 2007, 6:39 AM
By default, it is not. See if this post (http://extjs.com/forum/showthread.php?p=90692#post90692) helps.

stumpy_uk
26 Nov 2007, 7:39 AM
Doug,

I have done that but not sure how to use these values, to try to explain I have



Ext.state.Manager.setProvider(new Ext.state.CookieProvider({name: "Portalloader"}));

// create some portlet tools using built in Ext tool ids
var tools = [{
id:'gear',
handler: function(){
Ext.Msg.alert('Message', 'The Settings tool was clicked.');
}
},{
id:'close',
handler: function(e, target, panel){
panel.ownerCt.remove(panel, true);
}
}];

var panelStateEvents = ["drop","close","collapse","expand"];
var viewport = new Ext.Viewport({
layout:'border',
items:[{
xtype:'portal',
stateid: 'Workspace',
stateEvents: panelStateEvents,



And I can see in the cookies the following being written for the panels, but I am stumped on what to do next and how to use these to return the viewport to its last state.



ys-WebLink
null
apprstcsewrk009.ho.testdomain.co.uk/
1088
667801216
34459479
2704583376
29896769
*
ys-LastASK
null
apprstcsewrk009.ho.testdomain.co.uk/
1088
667801216
34459479
3942799856
29896764
*
ys-Risk
null
apprstcsewrk009.ho.testdomain.co.uk/
1088
667801216
34459479
3263680672
29896768
*

hendricd
26 Nov 2007, 7:47 AM
The viewPort is likely NOT a good candidate for state persistence as it only attaches itself to document.body as reflow container for embedded items.

You should look to the child panels to save their state instead.

stumpy_uk
26 Nov 2007, 9:15 AM
Doug,

Firstly thanks for trying to help me with this it is very much appreciated.

I did try the panels that at the beginning but when I add them into the Viewport I get cookie information created on the actual panels information, when I add them in the individual Panel items nothing happens, its driving me insane as I am completely stumped (pardon the pun on my username!)

This is what I had originally to try and capture the panel events within the Viewport but it shows nothing.



var panelStateEvents = ["move","close","collapse","expand"];
var viewport = new Ext.Viewport({
layout:'border',
items:[{
xtype:'portal',
stateid: 'Workspace',
region:'center',
margins:'35 5 5 5',
items:[{
columnWidth:.33,
style:'padding:10px 0 10px 10px',
items:[{
id: 'WebLink',
stateid: 'Weblink',
stateEvents: panelStateEvents,
title: 'Web Links',
autoLoad:'WebLinks.htm'
},{
id: 'LastASK',
stateid: 'LastASK',
stateEvents: panelStateEvents,
title: 'Latest ASK Updates',
autoLoad:'NewASk.asp'
}]
},{


When if I add the events to viewport i do at least get


ys-LastASK
null
apprstcsewrk009.ho.testdomain.co.uk/
1088
667801216
34459479
3942799856
29896764

But i have no clue what they mean, their config etc etc. I really am at a loss and I haev seen so many others ask this question and no-one has published any answer I have found.

hendricd
26 Nov 2007, 9:33 AM
We need to scope the goal first.

What attributes of what components do you want to persist in the cookie and restore later ?

stumpy_uk
27 Nov 2007, 1:05 AM
Doug,

I want to know where they were moved to and if they were minimised or maximised, in my app there is no close button so I dont need to worry about them, although in my state events I did take them into account.


var panelStateEvents = ["move","close","collapse","expand"];

Cheers

Lee

hendricd
27 Nov 2007, 8:32 AM
Boy, you want it all don't ya. ;)

I don't really have the time to dig into this. It won't be trivial. Since the viewport is the only container that maintains the layout of all its items, you'll likely have to make the viewport state-aware after-all .

You could try (using the post I gave you early) adapting getState methods for each panel and consolidate them into the viewPorts' overall state (somehow)

you'll likely need custom saveState handling at all levels.
:-?

jonx
12 Mar 2008, 12:56 AM
Hello, here is a small part of the solution: persist the expanded state of the panel:
http://extjs.com/forum/newreply.php?do=newreply&p=137017

I need the rest also ;)