Bug #24335
closedAdd ExtDirect Stateprovider for ExtJs States
0%
Description
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()) }; }
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); }
(issue imported from #M16738)
Files
Updated by Steffen Kamper almost 14 years ago
- depth combo
- table combo
- grid states