Observable Proxy
Package: | Ext.data |
Defined In: | Proxy.js |
Class: | Proxy |
Subclasses: | ClientProxy, ServerProxy |
Extends: | Observable |
Proxies are used by Stores to handle the loading and saving of Model data. Usually developers will not need to create or interact with proxies directly.
Types of Proxy
There are two main types of Proxy - Client and Server. The Client proxies save their data locally and include the following subclasses:
The Server proxies save their data by sending requests to some remote server. These proxies include:
Proxies operate on the principle that all operations performed are either Create, Read, Update or Delete. These four operations are mapped to the methods create, read, update and destroy respectively. Each Proxy subclass implements these functions.
The CRUD methods each expect an operation object as the sole argument. The Operation encapsulates information about the action the Store wishes to perform, the model instances that are to be modified, etc. See the Operation documentation for more details. Each CRUD method also accepts a callback function to be called asynchronously on completion.
Proxies also support batching of Operations via a batch object, invoked by the batch method.
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 | |
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 | |
---|---|---|
Proxy( Object config )
Creates the Proxy Creates the Proxy Parameters:
| Proxy | |
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 | |
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 )
:
voidPerforms the given read operation. Performs the given read operation. Parameters:
| Proxy | |
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 |