Ext.NET
5.3.0
.NET Component Framework for Enterprise Level Apps
|
The LocalStorageProxy uses the new HTML5 localStorage API to save Model data locally on the client browser. HTML5 localStorage is a key-value store (e.g. cannot save complex objects like JSON), so LocalStorageProxy automatically serializes and deserializes data when saving and retrieving it. More...
Classes | |
class | Builder |
class | Config |
Public Member Functions | |
LocalStorageProxy () | |
LocalStorageProxy.Builder | ToBuilder () |
override IControlBuilder | ToNativeBuilder () |
LocalStorageProxy (Config config) | |
Public Member Functions inherited from Ext.Net.WebStorageProxy | |
virtual void | Clear () |
Destroys all records stored in the proxy and removes all keys and values used to support the proxy from the storage object More... | |
virtual void | SetRecord (object record, string id) |
Saves the given record in the Proxy. Runs each field's encode function (if present) to encode the data More... | |
Public Member Functions inherited from Ext.Net.BaseItem | |
virtual bool | HasExplicitValue (string name) |
void | EnsureDataBind () |
virtual void | Call (string name) |
virtual void | Call (string name, params object[] args) |
virtual void | AddScript (string script) |
virtual void | AddScript (string script, params object[] args) |
virtual bool | IsEmptyObject () |
T | Apply< T > (IApply config) |
BaseItem | Apply (object config) |
virtual void | LoadViewState (object state) |
virtual object | SaveViewState () |
virtual void | TrackViewState () |
void | SetDirty () |
virtual void | DataBind () |
Static Public Member Functions | |
static implicit | operator LocalStorageProxy (LocalStorageProxy.Config config) |
Properties | |
override string | InstanceOf [get] |
override string | Type [get] |
Alias More... | |
override ConfigOptionsCollection | ConfigOptions [get] |
Properties inherited from Ext.Net.WebStorageProxy | |
override string | InstanceOf [get] |
virtual string?? | StorageID [get, set] |
The unique ID used as the key in which all record data are stored in the local storage object More... | |
override ConfigOptionsCollection | ConfigOptions [get] |
Properties inherited from Ext.Net.AbstractProxy | |
override string | InstanceOf [get] |
abstract string | Type [get] |
Alias More... | |
virtual bool | BatchActions [get, set] |
True to batch actions of a particular type when synchronizing the store. Defaults to true. More... | |
virtual string | BatchOrder [get, set] |
Comma-separated ordering 'create', 'update' and 'destroy' actions when batching. Override this to set a different order for the batched CRUD actions to be executed in. Defaults to 'create,update,destroy' More... | |
string | PropertyName [get] |
override ConfigOptionsCollection | ConfigOptions [get] |
Properties inherited from Ext.Net.BaseItem | |
virtual string | InstanceOf [get] |
ItemState | State [get] |
virtual DefaultValueMode | DefaultValueMode [get, set] |
virtual bool | DesignMode [get] |
bool | AutoDataBind [get, set] |
ResourceManager | ResourceManager [get] |
virtual Control | Owner [get, set] |
The Owner Control for this Listener. More... | |
virtual bool | IsDefault [get] |
Does this object currently represent it's default state. More... | |
bool | IsTrackingViewState [get] |
EventHandlerList | Events [get] |
EventHandler | DataBinding |
Control?? | BindingContainer [get] |
virtual ConfigItemCollection?? | CustomConfig [get] |
Collection of custom js config More... | |
virtual ConfigOptionsCollection | ConfigOptions [get] |
virtual ConfigOptionsExtraction | ConfigOptionsExtraction [get] |
System.Web.Mvc.HtmlHelper?? | HtmlHelper [get, set] |
Properties inherited from Ext.Net.IXObject | |
ConfigOptionsCollection | ConfigOptions [get] |
ConfigOptionsExtraction | ConfigOptionsExtraction [get] |
DefaultValueMode | DefaultValueMode [get, set] |
Properties inherited from Ext.Net.IAlias | |
string | PropertyName [get] |
Additional Inherited Members | |
Protected Member Functions inherited from Ext.Net.BaseItem | |
BaseItem (Control owner) | |
BaseItem () | |
virtual void | OwnerUpdate (Control owner) |
virtual void | OnDataBinding (EventArgs e) |
The LocalStorageProxy uses the new HTML5 localStorage API to save Model data locally on the client browser. HTML5 localStorage is a key-value store (e.g. cannot save complex objects like JSON), so LocalStorageProxy automatically serializes and deserializes data when saving and retrieving it.
localStorage is extremely useful for saving user-specific information without needing to build server-side infrastructure to support it. Let's imagine we're writing a Twitter search application and want to save the user's searches locally so they can easily perform a saved search again later. We'd start by creating a Search model:
Ext.regModel('Search', { fields: ['id', 'query'],
proxy: { type: 'localstorage', id : 'twitter-Searches' } }); Our Search model contains just two fields - id and query - plus a Proxy definition. The only configuration we need to pass to the LocalStorage proxy is an id. This is important as it separates the Model data in this Proxy from all others. The localStorage API puts all data into a single shared namespace, so by setting an id we enable LocalStorageProxy to manage the saved Search data.
Saving our data into localStorage is easy and would usually be done with a Store:
//our Store automatically picks up the LocalStorageProxy defined on the Search model var store = new Ext.data.Store({ model: "Search" });
//loads any existing Search data from localStorage store.load();
//now add some Searches store.add({query: 'Sencha Touch'}); store.add({query: 'Ext JS'});
//finally, save our Search data to localStorage store.sync(); The LocalStorageProxy automatically gives our new Searches an id when we call store.sync(). It encodes the Model data and places it into localStorage. We can also save directly to localStorage, bypassing the Store altogether:
var search = Ext.ModelManager.create({query: 'Sencha Animator'}, 'Search');
//uses the configured LocalStorageProxy to save the new Search to localStorage search.save(); Limitations
If this proxy is used in a browser where local storage is not supported, the constructor will throw an error. A local storage proxy requires a unique ID which is used as a key in which all record data are stored in the local storage object.
It's important to supply this unique ID as it cannot be reliably determined otherwise. If no id is provided but the attached store has a storeId, the storeId will be used. If neither option is presented the proxy will throw an error.
|
inline |
|
inline |
|
inlinestatic |
|
inline |
|
inlinevirtual |
Reimplemented from Ext.Net.BaseItem.
|
get |
|
get |
|
getprotected |
Alias