PDA

View Full Version : TabPanel applyState dont work



mx03
12 Jun 2013, 11:29 PM
Hi, i want to save the current tabs of an treepanel, but applyState get never called.
Its almost the same like http://dice.neko-san.net/2012/08/saving-state-of-an-ext-js-tabpanel-in-a-cookie/ , but it didn't work.
app.js

Ext.application({ name: 'TestApp',
autoCreateViewport: true,
appFolder: 'app',
launch: function(){
Ext.state.Manager.setProvider(Ext.create('Ext.state.LocalStorageProvider'));
}
});

viewport.js:

Ext.define('TestApp.view.Viewport', { extend: 'Ext.container.Viewport',
layout: 'border',
id : 'viewport',
initComponent: function()
{
var me = this;
me.items = [{
xtype: 'tabpanel',
region: 'center',
stateId: 'tabd',
stateful: true,
stateEvents: ['tabchange'],
listeners: {
"beforestaterestore": function(){
console.log("beforerestore");
}
},
getState: function(){
console.log("getstate");
return {
activeTab: {'test':"test"}
};
},
applyState: function(s){
console.log("setstate",s,arguments);
},
items: [{
id: 'c0',
title: 'Tab One'
}, {
id: 'c1',
title: 'Tab Two'
}, {
id: 'c2',
title: 'Tab Three'
}]
}];
me.callParent();
}
});

slemmon
16 Jun 2013, 9:16 PM
What if you put:
Ext.state.Manager.setProvider(Ext.create('Ext.state.LocalStorageProvider'));
inside of the app's init: function () {}
instead of the app's launch: function () {}