1 <!DOCTYPE html><html><head><title>Sencha Documentation Project</title><link rel="stylesheet" href="../reset.css" type="text/css"><link rel="stylesheet" href="../prettify.css" type="text/css"><link rel="stylesheet" href="../prettify_sa.css" type="text/css"><script type="text/javascript" src="../prettify.js"></script></head><body onload="prettyPrint()"><pre class="prettyprint"><pre><span id='Ext-form.action.DirectLoad'>/**
2 </span> * @class Ext.form.action.DirectLoad
3 * @extends Ext.form.action.Load
4 * <p>Provides {@link Ext.direct.Manager} support for loading form data.</p>
5 * <p>This example illustrates usage of Ext.direct.Direct to <b>load</b> a form through Ext.Direct.</p>
6 * <pre><code>
7 var myFormPanel = new Ext.form.Panel({
8 // configs for FormPanel
9 title: 'Basic Information',
10 renderTo: document.body,
11 width: 300, height: 160,
14 // configs apply to child items
15 defaults: {anchor: '100%'},
16 defaultType: 'textfield',
24 fieldLabel: 'Company',
28 // configs for BasicForm
30 // The server-side method to call for load() requests
31 load: Profile.getBasicInfo,
32 // The server-side must mark the submit handler as a 'formHandler'
33 submit: Profile.updateBasicInfo
35 // specify the order for the passed params
36 paramOrder: ['uid', 'foo']
40 myFormPanel.getForm().load({
41 // pass 2 arguments to server side getBasicInfo method (len=2)
47 * </code></pre>
48 * The data packet sent to the server will resemble something like:
49 * <pre><code>
52 "action":"Profile","method":"getBasicInfo","type":"rpc","tid":2,
53 "data":[34,"bar"] // note the order of the params
56 * </code></pre>
57 * The form will process a data packet returned by the server that is similar
58 * to the following format:
59 * <pre><code>
62 "action":"Profile","method":"getBasicInfo","type":"rpc","tid":2,
64 "success":true,
66 "name":"Fred Flintstone",
67 "company":"Slate Rock and Gravel",
68 "email":"fred.flintstone@slaterg.com"
73 * </code></pre>
75 Ext.define('Ext.form.action.DirectLoad', {
76 extend:'Ext.form.action.Load',
77 requires: ['Ext.direct.Manager'],
78 alternateClassName: 'Ext.form.Action.DirectLoad',
79 alias: 'formaction.directload',
84 this.form.api.load.apply(window, this.getArgs());
87 <span id='Ext-form.action.DirectLoad-method-getArgs'> /**
89 * Build the arguments to be sent to the Direct call.
96 paramOrder = form.paramOrder,
97 params = me.getParams(),
100 // If a paramOrder was specified, add the params into the argument list in that order.
102 for (i = 0, len = paramOrder.length; i < len; i++) {
103 args.push(params[paramOrder[i]]);
106 // If paramsAsHash was specified, add all the params as a single object argument.
107 else if (form.paramsAsHash) {
111 // Add the callback and scope to the end of the arguments list
112 args.push(me.onSuccess, me);
117 // Direct actions have already been processed and therefore
118 // we can directly set the result; Direct Actions do not have
119 // a this.response property.
120 processResponse: function(result) {
121 return (this.result = result);
124 onSuccess: function(result, trans) {
125 if (trans.type == Ext.direct.Manager.self.exceptions.SERVER) {
128 this.callParent([result]);
133 </pre></pre></body></html>