| api : ObjectSpecific urls to call on CRUD action methods "read", "create", "update" and "destroy".
+}
+ Below is a PHP example to do the same thing: $callback = $_REQUEST['callback'];
+
+// Create the output object.
+$output = array('a' => 'Apple', 'b' => 'Banana');
+
+//start output
+if ($callback) {
+ header('Content-Type: text/javascript');
+ echo $callback . '(' . json_encode($output) . ');';
+} else {
+ header('Content-Type: application/x-json');
+ echo json_encode($output);
+}
+ Below is the ASP.Net code to do the same thing: String jsonString = "{success: true}";
+String cb = Request.Params.Get("callback");
+String responseString = "";
+if (!String.IsNullOrEmpty(cb)) {
+ responseString = cb + "(" + jsonString + ")";
+} else {
+ responseString = jsonString;
+}
+Response.Write(responseString);
Config Options|
| api : ObjectSpecific urls to call on CRUD action methods "read", "create", "update" and "destroy".
Defaults to:api: {
read ... Specific urls to call on CRUD action methods "read", "create", "update" and "destroy".
Defaults to: api: {
@@ -36,6 +58,24 @@ Defaults to:api: {
update : undefined,
destroy : undefined
}
+The url is built based upon the action being executed [load|create|save|destroy]
+using the commensurate api property, or if undefined default to the
+configured Ext.data.Store.url.
+For example:
+api: {
+ load : '/controller/load',
+ create : '/controller/new', // Server MUST return idProperty of new record
+ save : '/controller/update',
+ destroy : '/controller/destroy_action'
+}
+
+// Alternatively, one can use the object-form to specify each API-action
+api: {
+ load: {url: 'read.php', method: 'GET'},
+ create: 'create.php',
+ destroy: 'destroy.php',
+ save: 'update.php'
+}
If the specific URL for a given CRUD action is undefined, the CRUD action request
will be directed to the configured url.
Note: To modify the URL for an action dynamically the appropriate API
@@ -52,22 +92,9 @@ myStore.on({
// permanent, applying this URL for all subsequent requests.
store.proxy.setUrl('changed1.php', true);
- // manually set the private connection URL.
- // Warning: Accessing the private URL property should be avoided.
- // Use the public method setUrl instead, shown above.
- // It should be noted that changing the URL like this will affect
- // the URL for just this request. Subsequent requests will use the
- // API or URL defined in your initial proxy configuration.
- store.proxy.conn.url = 'changed1.php';
-
- // proxy URL will be superseded by API (only if proxy created to use ajax):
- // It should be noted that proxy API changes are permanent and will
- // be used for all subsequent requests.
- store.proxy.api.load = 'changed2.php';
-
- // However, altering the proxy API should be done using the public
- // method setApi instead.
- store.proxy.setApi('load', 'changed2.php');
+ // Altering the proxy API should be done using the public
+ // method setApi.
+ store.proxy.setApi('read', 'changed2.php');
// Or set the entire API with a config-object.
// When using the config-object option, you must redefine the entire
@@ -85,9 +112,9 @@ myStore.on({
the server the name of the callback function set up by t...
The name of the parameter to pass to the server which tells
the server the name of the callback function set up by the load call to process the returned data object.
Defaults to "callback". The server-side processing must read this parameter value, and generate
-javascript output which calls this named function passing the data object as its only parameter. | ScriptTagProxy | | doRequest : Function Abstract method that should be implemented in all subclasses
+javascript output which calls this named function passing the data object as its only parameter. | ScriptTagProxy | | doRequest : FunctionAbstract method that should be implemented in all subclasses. Note: Should only be used by custom-proxy developers.
... | DataProxy | | listeners : Object | DataProxy | | listeners : ObjectA 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.
@@ -143,7 +170,7 @@ Ext.DomObserver = Ext.extend(Object, {
mode: 'local',
triggerAction: 'all'
}); | Observable | | nocache : Boolean Defaults to true. Disable caching by adding a unique parameter
-name to the request. | ScriptTagProxy | | restful : BooleanDefaults to false. Set to true to operate in a RESTful manner.
+name to the request. | ScriptTagProxy | | onRead : FunctionAbstract method that should be implemented in all subclasses. Note: Should only be used by custom-proxy developers. ... Abstract method that should be implemented in all subclasses. Note: Should only be used by custom-proxy developers. Callback for read action. | DataProxy | | onWrite : FunctionAbstract method that should be implemented in all subclasses. Note: Should only be used by custom-proxy developers. ... Abstract method that should be implemented in all subclasses. Note: Should only be used by custom-proxy developers. Callback for create, update and destroy actions. | DataProxy | | restful : BooleanDefaults to false. Set to true to operate in a RESTful manner.
Note: this parameter will automatically be set to t... Defaults to false. Set to true to operate in a RESTful manner.
Note: this parameter will automatically be set to true if the
Ext.data.Store it is plugged into is set to restful: true . If the
@@ -155,7 +182,7 @@ actions sent to one url based upon the HTTP method, for example:
proxy: new Ext.data.HttpProxy({url:'/users'}); // all requests sent to /users
...
)}
-There is no api specified in the configuration of the proxy,
+If there is no api specified in the configuration of the proxy,
all requests will be marshalled to a single RESTful url (/users) so the serverside
framework can inspect the HTTP Method and act accordingly:
@@ -164,12 +191,24 @@ POST /users create
GET /users read
PUT /users/23 update
DESTROY /users/23 delete
- | DataProxy | | timeout : Number The number of milliseconds to wait for a response. Defaults to 30 seconds. | ScriptTagProxy | | url : String The URL from which to request the data object. | ScriptTagProxy |
Public PropertiesThis class has no public properties. Public Methods|
| ScriptTagProxy( Object config )
+
+If set to true, a non-phantom record's
+id will be appended to the url. Some MVC (e.g., Ruby on Rails,
+Merb and Django) support segment based urls where the segments in the URL follow the
+Model-View-Controller approach: someSite.com/controller/action/id
+Where the segments in the url are typically:
+- The first segment : represents the controller class that should be invoked.
+- The second segment : represents the class function, or method, that should be called.
+- The third segment : represents the ID (a variable typically passed to the method).
+
+
Refer to Ext.data.DataProxy.api for additional information. | DataProxy | | timeout : Number The number of milliseconds to wait for a response. Defaults to 30 seconds. | ScriptTagProxy | | url : String The URL from which to request the data object. | ScriptTagProxy |
Public PropertiesThis class has no public properties. Public Methods|
| ScriptTagProxy( Object config )
Parameters:config : ObjectA configuration object. Returns: | ScriptTagProxy | | abort()
:
- voidAbort the current server request. Abort the current server request. | ScriptTagProxy | | addEvents( Object object )
+ voidAbort the current server request. Abort the current server request. | ScriptTagProxy | | addEvents( Object|String o , string Optional. )
:
- voidUsed to define events on this Observable Used to define events on this Observable | Observable | | addListener( String eventName , Function handler , [Object scope ], [Object options ] )
+ 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. | 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:eventName : StringThe name of the event to listen for. handler : FunctionThe method the event invokes. scope : Object(optional) The scope (this reference) in which the handler function is executed.
If omitted, defaults to the object which fired the event. options : Object(optional) An object containing handler configuration.
@@ -190,8 +229,8 @@ Using the options argument, it is possible to combine different types of listene
A delayed, one-time listener.
myDataView.on('click', this.onClick, this, {
- single: true,
- delay: 100
+single: true,
+delay: 100
});
Attaching multiple handlers in 1 call
@@ -199,27 +238,27 @@ The method also allows for a single argument to be passed which is a config obje
which specify multiple handlers.
myGridPanel.on({
- 'click' : {
- fn: this.onClick,
- scope: this,
- delay: 100
- },
- 'mouseover' : {
- fn: this.onMouseOver,
- scope: this
- },
- 'mouseout' : {
- fn: this.onMouseOut,
- scope: this
- }
+'click' : {
+ fn: this.onClick,
+ scope: this,
+ delay: 100
+},
+'mouseover' : {
+ fn: this.onMouseOver,
+ scope: this
+},
+'mouseout' : {
+ fn: this.onMouseOut,
+ scope: this
+}
});
Or a shorthand syntax:
myGridPanel.on({
- 'click' : this.onClick,
- 'mouseover' : this.onMouseOver,
- 'mouseout' : this.onMouseOut,
- scope: this
+'click' : this.onClick,
+'mouseover' : this.onMouseOver,
+'mouseout' : this.onMouseOut,
+ scope: this
});
Returns: | Observable | | destroy()
:
voidDestroys the proxy by purging any event listeners and cancelling any active requests. Destroys the proxy by purging any event listeners and cancelling any active requests. | DataProxy | | doRequest( String action , Ext.data.Record/Ext.data.Record[] rs , Object params , Ext.data.DataReader reader , Function callback , Object scope , Object arg )
@@ -231,9 +270,41 @@ The function must be passed
- The Record block object
- The "arg" argument from the load function
- A boolean success indicator
- scope : ObjectThe scope in which to call the callback arg : ObjectAn optional argument which is passed to the callback as its second parameter. Returns: | ScriptTagProxy | | enableBubble( Object events )
+scope : ObjectThe scope (this reference) in which the callback function is executed. Defaults to the browser window. arg : ObjectAn optional argument which is passed to the callback as its second parameter. Returns: | ScriptTagProxy | | enableBubble( String/Array events )
:
- voidUsed to enable bubbling of events Used to enable bubbling of events | Observable | | fireEvent( String eventName , Object... args )
+ 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.getBubbleTarget() if present. There is no implementation in the Observable base class.
+ 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: Ext.override(Ext.form.Field, {
+ // Add functionality to Field's initComponent to enable the change event to bubble
+ initComponent : Ext.form.Field.prototype.initComponent.createSequence(function() {
+ this.enableBubble('change');
+ }),
+
+ // We know that we want Field's events to bubble directly to the FormPanel.
+ getBubbleTarget : function() {
+ if (!this.formPanel) {
+ this.formPanel = this.findParentByType('form');
+ }
+ return this.formPanel;
+ }
+});
+
+var myForm = new Ext.formPanel({
+ title: 'User Details',
+ items: [{
+ ...
+ }],
+ listeners: {
+ change: function() {
+ // Title goes red if form has been modified.
+ myForm.header.setStyle('color', 'red');
+ }
+ }
+});
| 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).
@@ -251,7 +322,11 @@ the corresponding code for CRUD action. Param
voidDeprecated load method using old method signature. See {@doRequest} for preferred method. Deprecated load method using old method signature. See {@doRequest} for preferred method. Parameters:params : Objectreader : Objectcallback : Objectscope : Objectarg : Object Returns: | DataProxy | | 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:eventName : StringThe type of event to listen for handler : FunctionThe method the event invokes scope : Object(optional) The scope (this reference) in which the handler function is executed.
-If omitted, defaults to the object which fired the event. options : Object(optional) An object containing handler configuration. Returns: | Observable | | purgeListeners()
+If omitted, defaults to the object which fired the event.options : Object(optional) An object containing handler configuration. Returns: | Observable | | onRead( String action , Object trans , Object res )
+ :
+ voidCallback for read actions Callback for read actions | ScriptTagProxy | | onWrite( String action , Object trans , Object res )
+ :
+ voidCallback for write actions Callback for write actions | ScriptTagProxy | | purgeListeners()
:
voidRemoves all listeners for this object Removes all listeners for this object | Observable | | relayEvents( Object o , Array events )
:
@@ -259,7 +334,7 @@ the corresponding code for CRUD action.Param
:
voidRemoves an event handler. Removes an event handler. | Observable | | request( String action , Ext.data.Record/Ext.data.Record[]/null rs , Object params , Ext.data.DataReader reader , Function callback , Object scope , Object options )
:
- voidAll proxy actions are executed through this method. Automatically fires the "before" + action event All proxy actions are executed through this method. Automatically fires the "before" + action event | DataProxy | | resumeEvents()
+ voidAll proxy actions are executed through this method. Automatically fires the "before" + action event All proxy actions are executed through this method. Automatically fires the "before" + action event | DataProxy | | resumeEvents()
:
void | DataProxy | | beforewrite :
( DataProxy this , String action , Record/Array[Record] rs , Object params )
- Fires before a request is generated for one of the actions Ext.data.Api.actions.create|update|destroy Fires before a request is generated for one of the actions Ext.data.Api.actions.create|update|destroy Listeners will be called with the following arguments:this : DataProxyThe proxy for the request action : String[Ext.data.Api.actions.create|update|destroy] rs : Record/Array[Record]The Record(s) to create|update|destroy. params : ObjectThe request params object. Edit params to add parameters to the request.
| DataProxy | | exception :
+ Fires before a request is generated for one of the actions Ext.data.Api.actions.create|update|destroy
+In addition to... Fires before a request is generated for one of the actions Ext.data.Api.actions.create|update|destroy
+ In addition to being fired through the DataProxy instance that raised the event, this event is also fired
+through the Ext.data.DataProxy class to allow for centralized processing of beforewrite events from all
+DataProxies by attaching a listener to the Ext.data.Proxy class itself. Listeners will be called with the following arguments:this : DataProxyThe proxy for the request action : String[Ext.data.Api.actions.create|update|destroy] rs : Record/Array[Record]The Record(s) to create|update|destroy. params : ObjectThe request params object. Edit params to add parameters to the request.
| DataProxy | | exception :
( DataProxy this , String type , String action , Object options , Object response , Mixed arg )
- Fires if an exception occurs in the Proxy during a remote request.
-This event is relayed through a corresponding
-Ex... Fires if an exception occurs in the Proxy during a remote request.
-This event is relayed through a corresponding
-Ext.data.Store.exception,
-so any Store instance may observe this event.
-This event can be fired for one of two reasons:
+ Fires if an exception occurs in the Proxy during a remote request. This event is relayed
+through a corresponding Ext... Fires if an exception occurs in the Proxy during a remote request. This event is relayed
+through a corresponding Ext.data.Store.exception,
+so any Store instance may observe this event.
+ In addition to being fired through the DataProxy instance that raised the event, this event is also fired
+through the Ext.data.DataProxy class to allow for centralized processing of exception events from all
+DataProxies by attaching a listener to the Ext.data.Proxy class itself.
+ This event can be fired for one of two reasons:
- remote-request failed :
The server did not return status === 200.
@@ -357,4 +437,8 @@ on any Store instance. The callback's arg object passed to the load function e : ErrorThe JavaScript Error object caught if the configured Reader could not read the data.
If the remote request returns success: false, this parameter will be null. | ScriptTagProxy | | write :
( DataProxy this , String action , Object data , Object response , Record/Record{} rs , Object options )
- Fires before the request-callback is called Fires before the request-callback is called Listeners will be called with the following arguments:this : DataProxyThe proxy that sent the request action : String[Ext.data.Api.actions.create|upate|destroy] data : ObjectThe data object extracted from the server-response response : ObjectThe decoded response from server rs : Record/Record{}The records from Store options : ObjectThe callback's options property as passed to the request function
| DataProxy |
\ No newline at end of file
+ Fires before the request-callback is called
+In addition to being fired through the DataProxy instance that raised th... Fires before the request-callback is called
+ In addition to being fired through the DataProxy instance that raised the event, this event is also fired
+through the Ext.data.DataProxy class to allow for centralized processing of write events from all
+DataProxies by attaching a listener to the Ext.data.Proxy class itself. Listeners will be called with the following arguments:this : DataProxyThe proxy that sent the request action : String[Ext.data.Api.actions.create|upate|destroy] data : ObjectThe data object extracted from the server-response response : ObjectThe decoded response from server rs : Record/Record{}The records from Store options : ObjectThe callback's options property as passed to the request function
| DataProxy |