Observable Proxy ClientProxy 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 | Defined By | |
---|---|---|
batchOrder : String Comma-separated ordering 'create', 'update' and 'destroy' actions when batching. Override this
to set a different ord... 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' | Proxy | |
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 | |
listeners : Object A config object containing one or more event handlers to be added to this
object during initialization. This should ... A config object containing one or more event handlers to be added to this object during initialization. This should be a valid listeners config object as specified in the addListener example for attaching multiple handlers at once. DOM events from ExtJs Components While some ExtJs Component classes export selected DOM events (e.g. "click", "mouseover" etc), this
is usually only done when extra value can be added. For example the DataView's
| Observable |
Method | Defined By | |
---|---|---|
addEvents( Object|String o , string Optional. )
:
voidAdds the specified events to the list of events which this Observable may fire. Adds the specified events to the list of events which this Observable may fire. Parameters:
| Observable | |
addListener( String eventName , Function handler , [Object scope ], [Object options ] )
:
voidAppends an event handler to this object. Appends an event handler to this object. Parameters:
| Observable | |
addManagedListener( Observable|Element item , Object|String ename , Function fn , Object scope , Object opt )
:
voidAdds listeners to any Observable object (or Element) which are automatically removed when this Component
is destroyed... Adds listeners to any Observable object (or Element) which are automatically removed when this Component is destroyed. Parameters:
| Observable | |
batch( Object operations , Object listeners )
:
Ext.data.BatchPerforms a batch of Operations, in the order specified by batchOrder. Used internally by
Ext.data.Store's sync method... Performs a batch of Operations, in the order specified by batchOrder. Used internally by
Ext.data.Store's sync method. Example usage:
Where the myModel* above are Model instances - in this case 1 and 2 are new instances and have not been
saved before, 3 has been saved previously but needs to be updated, and 4 and 5 have already been saved but should now be destroyed.Parameters:
| Proxy | |
clear()
:
void Abstract function that must be implemented by each ClientProxy subclass. This should purge all record data
from the c... Abstract function that must be implemented by each ClientProxy subclass. This should purge all record data
from the client side storage, as well as removing any supporting data (such as lists of record IDs) Parameters:
| ClientProxy | |
clearListeners()
:
void Removes all listeners for this object including the managed listeners Removes all listeners for this object including the managed listeners Parameters:
| Observable | |
clearManagedListeners()
:
void Removes all managed listeners for this object. Removes all managed listeners for this object. Parameters:
| Observable | |
create( Ext.data.Operation operation , Function callback , Object scope )
:
voidPerforms the given create operation. Performs the given create operation. Parameters:
| Proxy | |
destroy( Ext.data.Operation operation , Function callback , Object scope )
:
voidPerforms the given destroy operation. Performs the given destroy operation. Parameters:
| Proxy | |
enableBubble( String/Array events )
:
voidEnables events fired by this Observable to bubble up an owner hierarchy by calling
this.getBubbleTarget() if present.... Enables events fired by this Observable to bubble up an owner hierarchy by calling
This is commonly used by Ext.Components to bubble events to owner Containers. See Ext.Component.getBubbleTarget. The default implementation in Ext.Component returns the Component's immediate owner. But if a known target is required, this can be overridden to access the required target more quickly. Example:
Parameters:
| Observable | |
fireEvent( String eventName , Object... args )
:
BooleanFires the specified event with the passed parameters (minus the event name).
An event may be set to bubble up an Obse... Fires the specified event with the passed parameters (minus the event name). An event may be set to bubble up an Observable parent hierarchy (See Ext.Component.getBubbleTarget) by calling enableBubble. Parameters:
| Observable | |
getModel()
:
Ext.data.Model Returns the model attached to this Proxy Returns the model attached to this Proxy Parameters:
| Proxy | |
getReader()
:
Ext.data.Reader Returns the reader currently attached to this proxy instance Returns the reader currently attached to this proxy instance Parameters:
| Proxy | |
getWriter()
:
Ext.data.Writer Returns the writer currently attached to this proxy instance Returns the writer currently attached to this proxy instance Parameters:
| Proxy | |
hasListener( String eventName )
:
BooleanChecks to see if this object has any listeners for a specified event Checks to see if this object has any listeners for a specified event Parameters:
| Observable | |
on( String eventName , Function handler , [Object scope ], [Object options ] )
:
voidAppends an event handler to this object (shorthand for addListener.) Appends an event handler to this object (shorthand for addListener.) Parameters:
| Observable | |
read( Ext.data.Operation operation , Function callback , Object scope )
:
voidReads data from the configured data object. Uses the Proxy's reader, if present | MemoryProxy | |
relayEvents( Object o , Array events )
:
voidRelays selected events from the specified Observable as if the events were fired by this. Relays selected events from the specified Observable as if the events were fired by this. Parameters:
| Observable | |
removeListener( String eventName , Function handler , [Object scope ] )
:
voidRemoves an event handler. Removes an event handler. Parameters:
| Observable | |
removeManagedListener( Observable|Element item , Object|String ename , Function fn , Object scope )
:
voidRemoves listeners that were added by the mon method. Removes listeners that were added by the mon method. Parameters:
| Observable | |
resumeEvents()
:
void Resume firing events. (see suspendEvents)
If events were suspended using the queueSuspended parameter, then all
event... Resume firing events. (see suspendEvents)
If events were suspended using the queueSuspended parameter, then all
events fired during event suspension will be sent to any listeners now. Parameters:
| Observable | |
setModel( String|Ext.data.Model model , Boolean setOnStore )
:
voidSets the model associated with this proxy. This will only usually be called by a Store Sets the model associated with this proxy. This will only usually be called by a Store Parameters:
| Proxy | |
setReader( String|Object|Ext.data.Reader reader )
:
Ext.data.ReaderSets the Proxy's Reader by string, config object or Reader instance Sets the Proxy's Reader by string, config object or Reader instance Parameters:
| Proxy | |
setWriter( String|Object|Ext.data.Writer writer )
:
Ext.data.WriterSets the Proxy's Writer by string, config object or Writer instance Sets the Proxy's Writer by string, config object or Writer instance Parameters:
| Proxy | |
suspendEvents( Boolean queueSuspended )
:
voidSuspend the firing of all events. (see resumeEvents) Suspend the firing of all events. (see resumeEvents) Parameters:
| Observable | |
un( String eventName , Function handler , [Object scope ] )
:
voidRemoves an event handler (shorthand for removeListener.) Removes an event handler (shorthand for removeListener.) Parameters:
| Observable | |
update( Ext.data.Operation operation , Function callback , Object scope )
:
voidPerforms the given update operation. Performs the given update operation. Parameters:
| Proxy |