开发者

How to use Ext.state.LocalStorageProvider?

开发者 https://www.devze.com 2023-04-07 21:23 出处:网络
How to setup Ext.state.LocalStorageProvide开发者_运维百科r so it saves states for all items?LocalStorageProvide is a HTML5 Local Storage wrapper for Ext JS. You can make use of the local storage provi

How to setup Ext.state.LocalStorageProvide开发者_运维百科r so it saves states for all items?


LocalStorageProvide is a HTML5 Local Storage wrapper for Ext JS. You can make use of the local storage provided the browser you use support it.

The storage is based on key/value pairs. You can store up to 5MB (I think thats the specification and some browsers don't provide that much space. I am not sure of the size limit) and use simple APIs of the LocalStorageProvider to store and retrieve data. Storing the state is NOT automated! You should know when to store, and when to retrieve!

You can make use of the set & get method to store and retrieve values. Here is an example:

 var store = Ext.state.LocalStorageProvider.create();  
 store.set('record',rec); //This could be a object like (Ext.data.Model)

You can retrieve the data (may be in initComponent of a form etc) using:

var rec = store.get('record');
form.loadRecord(rec);  // Load the form with the saved data...
0

精彩评论

暂无评论...
验证码 换一张
取 消