PDA

View Full Version : [FIXED] Stateful implementation broken for panels in Accordion layout



stahlman
11 Oct 2011, 12:50 PM
I started with the "Complex Layout" example on the "Samples & Demos" page, adding unique stateId's to the west panel's 3 sub-panels (Navigation, Settings and Information), which are arranged in an Accordion layout. My expectation was that the collapsed state of all 3 panels would be remembered when the page was reloaded. It didn't work, however, because Ext.state.Stateful.onStateChange (and hence, saveState) is being called only for the panel being expanded - not for the one being collapsed.

Well, while researching the issue for this post, I found the root cause: the call to...

this.addStateEvents('expand', 'collapse');

...within Ext.panel.Panel.initComponent is invalid because the addStateEvents method expects either an array of Strings or a single String. When it's called as it is above, it registers only the first event name, ignoring all subsequent event names, with the result that onStateChange will be called only for an expanding panel. I fixed the issue by changing the call to...

this.addStateEvents([ 'expand', 'collapse' ]);

Thanks,
Brett Stahlman