[TYPO3-core] RFC: #16738: Add ExtDirect Stateprovider for ExtJs States

Steffen Kamper info at sk-typo3.de
Tue Dec 14 17:13:51 CET 2010


Hi,

This is an SVN patch request.

Type: cleanup

Bugtracker references:
http://bugs.typo3.org/view.php?id=16738

Branches:
Trunk

ExtJs has a built-in state provider which read/save states of 
components. It's mostly used with CookieProvider, but in TYPO3 we are 
used to save such infos in BE_USER->uc.

The attached patch adds an ExtDirect Stateprovider which saves all 
states in BE_USER->uc and is very simple to use:

1) Add the state provider to your module:

$this->doc->setExtDirectStateProvider();



2) Add the state provider in your ExtJs application:

Ext.state.Manager.setProvider(new TYPO3.state.ExtDirectProvider({
     key: 'yourKey'
}));



Key is a dotted notaion for the array key in BE_USER->uc. Eg in 
extension manager i use
key: 'moduleData.tools_em.States'

3) Make your components stateful
To achieve this, you have to set 3 properties:
stateful -> set to true to have automatic state read/save
stateId -> the name of the component used to save the data
stateEvents -> array of events where states should be readed/saved

Example for a grid:

stateful: true,
stateId: 'RepositoryList',
stateEvents: ['columnmove', 'columnresize', 'sortchange', 'groupchange'],



Example for a tabPanel:

stateId: 'mainTab',
stateEvents:['tabchange'],
getState:function() {
     return {
         activeTab:  this.items.indexOf(this.getActiveTab())
     };
}


Additional info:

For the initial state you have to set the state at the beginning of the 
App. This is different to cookie provider as the read is not finished 
when you initialize your component.

Here is an example how i do it in extension manager:

1) Write the state in TYPO3,settings

$settings['state'] = 
$GLOBALS['BE_USER']->uc['moduleData']['tools_em']['States'];
$this->pageRenderer->addInlineSettingArray('EM', $settings);


2) Init the states in js APP

if (Ext.isObject(TYPO3.settings.EM.States)) {
     Ext.state.Manager.getProvider().initState(TYPO3.settings.EM.States);
}


I attached also a patch for recycler where the provider get used. This 
is a good test case.
Following states are saved:
* depth combo
* table combo
* grid states

vg Steffen
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: 16738.patch
URL: <http://lists.typo3.org/pipermail/typo3-team-core/attachments/20101214/ce6d2f6f/attachment-0001.asc>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: 16738_recycler_usage.patch
URL: <http://lists.typo3.org/pipermail/typo3-team-core/attachments/20101214/ce6d2f6f/attachment-0001.txt>


More information about the TYPO3-team-core mailing list