Project

General

Profile

Actions

Bug #24335

closed

Add ExtDirect Stateprovider for ExtJs States

Added by Steffen Kamper over 13 years ago. Updated about 13 years ago.

Status:
Closed
Priority:
Should have
Category:
-
Target version:
-
Start date:
2010-12-14
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
4.5
PHP Version:
5.3
Tags:
Complexity:
Is Regression:
Sprint Focus:

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

16738.patch (12.1 KB) 16738.patch Administrator Admin, 2010-12-14 16:20
16738_recycler_usage.patch (2.37 KB) 16738_recycler_usage.patch Administrator Admin, 2010-12-14 17:09

Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #24592: StateProvider values not respectedClosedSteffen Kamper2011-01-15

Actions
Actions #1

Updated by Steffen Kamper over 13 years ago

I attached a patch which demonstrate the usage in recycler. Following states are saved:
  • depth combo
  • table combo
  • grid states
Actions #2

Updated by Steffen Kamper over 13 years ago

committed to trunk rev 9831

Actions #3

Updated by Susanne Moog about 13 years ago

  • Target version deleted (4.5.0)
Actions

Also available in: Atom PDF