3 <title>The source code</title>
\r
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
7 <body onload="prettyPrint();">
\r
8 <pre class="prettyprint lang-js">// This example illustrates how to load a FormPanel or BasicForm through Ext.Direct.
10 Ext.onReady(function(){
11 // Notice that Direct requests will batch together if they occur
12 // within the enableBuffer delay period (in milliseconds).
13 // Slow the buffering down from the default of 10ms to 100ms
14 Ext.app.REMOTING_API.enableBuffer = 100;
15 Ext.Direct.addProvider(Ext.app.REMOTING_API);
17 // provide feedback for any errors
20 var basicInfo = new Ext.form.FormPanel({
21 // configs for FormPanel
22 title: 'Basic Information',
28 basicInfo.getForm().submit({
37 // configs apply to child items
38 defaults: {anchor: '-20'}, // provide some room on right for validation errors
39 defaultType: 'textfield',
48 fieldLabel: 'Company',
52 // configs for BasicForm
54 // The server-side method to call for load() requests
55 load: Profile.getBasicInfo,
56 // The server-side must mark the submit handler as a 'formHandler'
57 submit: Profile.updateBasicInfo
59 // specify the order for the passed params
60 paramOrder: ['uid', 'foo']
63 var phoneInfo = new Ext.form.FormPanel({
64 title: 'Phone Numbers',
67 load: Profile.getPhoneInfo
71 defaultType: 'textfield',
72 defaults: {anchor: '100%'},
85 var locationInfo = new Ext.form.FormPanel({
86 title: 'Location Information',
90 load: Profile.getLocationInfo
93 defaultType: 'textfield',
94 defaults: {anchor: '100%'},
110 var accordion = new Ext.Panel({
112 renderTo: Ext.getBody(),
116 items: [basicInfo, phoneInfo, locationInfo]
119 // load the forms (notice the load requests will get batched together)
120 basicInfo.getForm().load({
121 // pass 2 arguments to server side getBasicInfo method (len=2)
128 phoneInfo.getForm().load({
134 // defer this request just to simulate the request not getting batched
135 // since it exceeds to configured buffer
137 locationInfo.getForm().load({
145 TestAction.doEcho('sample');