You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

162 lines
4.4 KiB

2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. This file is part of Ext JS 3.4
  3. Copyright (c) 2011-2013 Sencha Inc
  4. Contact: http://www.sencha.com/contact
  5. GNU General Public License Usage
  6. This file may be used under the terms of the GNU General Public License version 3.0 as
  7. published by the Free Software Foundation and appearing in the file LICENSE included in the
  8. packaging of this file.
  9. Please review the following information to ensure the GNU General Public License version 3.0
  10. requirements will be met: http://www.gnu.org/copyleft/gpl.html.
  11. If you are unsure which license is appropriate for your use, please contact the sales department
  12. at http://www.sencha.com/contact.
  13. Build date: 2013-04-03 15:07:25
  14. */
  15. // This example illustrates how to load a FormPanel or BasicForm through Ext.Direct.
  16. Ext.onReady(function(){
  17. // Notice that Direct requests will batch together if they occur
  18. // within the enableBuffer delay period (in milliseconds).
  19. // Slow the buffering down from the default of 10ms to 100ms
  20. Ext.app.REMOTING_API.enableBuffer = 100;
  21. Ext.Direct.addProvider(Ext.app.REMOTING_API);
  22. // provide feedback for any errors
  23. Ext.QuickTips.init();
  24. var basicInfo = new Ext.form.FormPanel({
  25. // configs for FormPanel
  26. title: 'Basic Information',
  27. border: false,
  28. padding: 10,
  29. buttons:[{
  30. text: 'Submit',
  31. handler: function(){
  32. basicInfo.getForm().submit({
  33. params: {
  34. foo: 'bar',
  35. uid: 34
  36. }
  37. });
  38. }
  39. }],
  40. // configs apply to child items
  41. defaults: {anchor: '-20'}, // provide some room on right for validation errors
  42. defaultType: 'textfield',
  43. items: [{
  44. fieldLabel: 'Name',
  45. name: 'name'
  46. },{
  47. fieldLabel: 'Email',
  48. msgTarget: 'side',
  49. name: 'email'
  50. },{
  51. fieldLabel: 'Company',
  52. name: 'company'
  53. }],
  54. // configs for BasicForm
  55. api: {
  56. // The server-side method to call for load() requests
  57. load: Profile.getBasicInfo,
  58. // The server-side must mark the submit handler as a 'formHandler'
  59. submit: Profile.updateBasicInfo
  60. },
  61. // specify the order for the passed params
  62. paramOrder: ['uid', 'foo']
  63. });
  64. var phoneInfo = new Ext.form.FormPanel({
  65. title: 'Phone Numbers',
  66. border: false,
  67. api: {
  68. load: Profile.getPhoneInfo
  69. },
  70. padding: 10,
  71. paramOrder: ['uid'],
  72. defaultType: 'textfield',
  73. defaults: {anchor: '100%'},
  74. items: [{
  75. fieldLabel: 'Office',
  76. name: 'office'
  77. },{
  78. fieldLabel: 'Cell',
  79. name: 'cell'
  80. },{
  81. fieldLabel: 'Home',
  82. name: 'home'
  83. }]
  84. });
  85. var locationInfo = new Ext.form.FormPanel({
  86. title: 'Location Information',
  87. border: false,
  88. padding: 10,
  89. api: {
  90. load: Profile.getLocationInfo
  91. },
  92. paramOrder: ['uid'],
  93. defaultType: 'textfield',
  94. defaults: {anchor: '100%'},
  95. items: [{
  96. fieldLabel: 'Street',
  97. name: 'street'
  98. },{
  99. fieldLabel: 'City',
  100. name: 'city'
  101. },{
  102. fieldLabel: 'State',
  103. name: 'state'
  104. },{
  105. fieldLabel: 'Zip',
  106. name: 'zip'
  107. }]
  108. });
  109. var accordion = new Ext.Panel({
  110. layout: 'accordion',
  111. layoutConfig: {
  112. autoWidth : false
  113. },
  114. renderTo: Ext.getBody(),
  115. title: 'My Profile',
  116. width: 300,
  117. height: 240,
  118. items: [basicInfo, phoneInfo, locationInfo]
  119. });
  120. // load the forms (notice the load requests will get batched together)
  121. basicInfo.getForm().load({
  122. // pass 2 arguments to server side getBasicInfo method (len=2)
  123. params: {
  124. foo: 'bar',
  125. uid: 34
  126. }
  127. });
  128. phoneInfo.getForm().load({
  129. params: {
  130. uid: 5
  131. }
  132. });
  133. // defer this request just to simulate the request not getting batched
  134. // since it exceeds to configured buffer
  135. (function(){
  136. locationInfo.getForm().load({
  137. params: {
  138. uid: 5
  139. }
  140. });
  141. }).defer(200);
  142. // rpc call
  143. TestAction.doEcho('sample');
  144. });