Properties Methods Events Config Options Direct Link
Observable
  Proxy
    ClientProxy
      MemoryProxy

Class Ext.data.MemoryProxy

Package:Ext.data
Defined In:MemoryProxy.js
Class:MemoryProxy
Extends:ClientProxy

In-memory proxy. This proxy simply uses a local variable for data storage/retrieval, so its contents are lost on every page refresh. Usually this Proxy isn't used directly, serving instead as a helper to a Store where a reader is required to load data. For example, say we have a Store for a User model and have some inline data we want to load, but this data isn't in quite the right format: we can use a MemoryProxy with a JsonReader to read it into our Store:

//this is the model we'll be using in the store
Ext.regModel('User', {
    fields: [
        {name: 'id',    type: 'int'},
        {name: 'name',  type: 'string'},
        {name: 'phone', type: 'string', mapping: 'phoneNumber'}
    ]
});

//this data doesn't line up to our model fields - the phone field is called phoneNumber
var data = {
    users: [
        {
            id: 1,
            name: 'Ed Spencer',
            phoneNumber: '555 1234'
        },
        {
            id: 2,
            name: 'Abe Elias',
            phoneNumber: '666 1234'
        }
    ]
};

//note how we set the 'root' in the reader to match the data structure above
var store = new Ext.data.Store({
    autoLoad: true,
    model: 'User',
    data : data,
    proxy: {
        type: 'memory',
        reader: {
            type: 'json',
            root: 'users'
        }
    }
});

Config Options

Config OptionsDefined By
 data : Array
Optional array of Records to load into the Proxy
MemoryProxy
 defaultReaderType : String
The default registered reader type. Defaults to 'json'
Proxy
 defaultWriterType : String
The default registered writer type. Defaults to 'json'
Proxy

Public Properties

This class has no public properties.

Public Methods

MethodDefined By

Public Events

This class has no public events.