PDA

View Full Version : Extend Window and state ?



uptodate
25 Aug 2010, 5:39 AM
// class :

pus.cls.wnd = Ext.extend(Ext.Window,{
stateEvents : ["resize", "position"],
stateful : true,
initComponent : function ()
{
//...
pus.cls.wnd.superclass.initComponent.call(this);
this.render(this.renderTo);
this.show();
}
});

// call :

var exampleWindow = new pus.cls.wnd({
stateId : 'myWindowState',
title : 'Example',
renderTo : Ext.getBody(),
height : 100,
width : 100
});
I have a extended Window.
When I resize or move the exampleWindow the state`s are not save.

A normal Ext.Window work with state.

Why does not work my extend window ? Is there a solution ?

uptodate
26 Aug 2010, 12:34 AM
no solution ?

Condor
27 Aug 2010, 1:46 AM
The event is called 'move' and not 'position'.

Did you register a provider with the state manager?

uptodate
27 Aug 2010, 2:00 AM
Yes, i have a state manager. A normal ExtJs Window work but not my extend window

Condor
27 Aug 2010, 2:36 AM
1. You don't need to specify stateEvents (Ext.Window.DD.endDrag and Ext.Window.handleResize already call saveState).
2. Your example should work! Can you test if you get beforestaterestore, staterestore, beforestatesave and statesave events?

uptodate
27 Aug 2010, 4:28 AM
the events are fired, but the the size of the window doesn`t change to the state size.

Original Window Size:

width : 550,
height: 300

Listeners on the Window :




...
listeners :
{
beforestaterestore : function(that, state)
{
console.log('beforestaterestore')
console.dir(state);
},
staterestore : function(that, state)
{
console.log('staterestore')
console.dir(state);
},
beforestatesave : function ()
{
console.log('beforestatesave');
},
statesave : function ()
{
console.log('statesave');
}
},
....

Firebug:

22159

Condor
27 Aug 2010, 4:40 AM
Yes, that is because the state is restored after initComponent is called, but you are already rendering and showing the window in initComponent, so setting x, y, width and height properties after that won't affect the window.

Try:

initComponent: function () {
//...
pus.cls.wnd.superclass.initComponent.call(this);
},
render: function() {
pus.cls.wnd.superclass.render.apply(this, arguments);
this.show();
}

uptodate
27 Aug 2010, 4:55 AM
thx condor this helps.

"this.render(this.renderTo);" I do not need more right?

Condor
27 Aug 2010, 5:36 AM
No, the standard handling of renderTo at the end of the Component constructor already takes care of that.