combination.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. function getCombinationLayouts() {
  2. // fake grid data used below in the tabsNestedLayouts config
  3. var myData = [
  4. ['3m Co', 71.72, 0.02, 0.03, '9/1 12:00am'],
  5. ['Alcoa Inc', 29.01, 0.42, 1.47, '9/1 12:00am'],
  6. ['Altria Group Inc', 83.81, 0.28, 0.34, '9/1 12:00am'],
  7. ['American Express Company', 52.55, 0.01, 0.02, '9/1 12:00am'],
  8. ['American International Group, Inc.', 64.13, 0.31, 0.49, '9/1 12:00am'],
  9. ['AT&T Inc.', 31.61, -0.48, -1.54, '9/1 12:00am'],
  10. ['Boeing Co.', 75.43, 0.53, 0.71, '9/1 12:00am'],
  11. ['Caterpillar Inc.', 67.27, 0.92, 1.39, '9/1 12:00am'],
  12. ['Citigroup, Inc.', 49.37, 0.02, 0.04, '9/1 12:00am'],
  13. ['E.I. du Pont de Nemours and Company', 40.48, 0.51, 1.28, '9/1 12:00am'],
  14. ['Exxon Mobil Corp', 68.1, -0.43, -0.64, '9/1 12:00am'],
  15. ['General Electric Company', 34.14, -0.08, -0.23, '9/1 12:00am'],
  16. ['General Motors Corporation', 30.27, 1.09, 3.74, '9/1 12:00am'],
  17. ['Hewlett-Packard Co.', 36.53, -0.03, -0.08, '9/1 12:00am'],
  18. ['Honeywell Intl Inc', 38.77, 0.05, 0.13, '9/1 12:00am'],
  19. ['Intel Corporation', 19.88, 0.31, 1.58, '9/1 12:00am'],
  20. ['International Business Machines', 81.41, 0.44, 0.54, '9/1 12:00am'],
  21. ['Johnson & Johnson', 64.72, 0.06, 0.09, '9/1 12:00am'],
  22. ['JP Morgan & Chase & Co', 45.73, 0.07, 0.15, '9/1 12:00am'],
  23. ['McDonald\'s Corporation', 36.76, 0.86, 2.40, '9/1 12:00am'],
  24. ['Merck & Co., Inc.', 40.96, 0.41, 1.01, '9/1 12:00am'],
  25. ['Microsoft Corporation', 25.84, 0.14, 0.54, '9/1 12:00am'],
  26. ['Pfizer Inc', 27.96, 0.4, 1.45, '9/1 12:00am'],
  27. ['The Coca-Cola Company', 45.07, 0.26, 0.58, '9/1 12:00am'],
  28. ['The Home Depot, Inc.', 34.64, 0.35, 1.02, '9/1 12:00am'],
  29. ['The Procter & Gamble Company', 61.91, 0.01, 0.02, '9/1 12:00am'],
  30. ['United Technologies Corporation', 63.26, 0.55, 0.88, '9/1 12:00am'],
  31. ['Verizon Communications', 35.57, 0.39, 1.11, '9/1 12:00am'],
  32. ['Wal-Mart Stores, Inc.', 45.45, 0.73, 1.63, '9/1 12:00am']
  33. ];
  34. /**
  35. * Custom function used for column renderer
  36. * @param {Object} val
  37. */
  38. function change(val) {
  39. if (val > 0) {
  40. return '<span style="color:green;">' + val + '</span>';
  41. } else if (val < 0) {
  42. return '<span style="color:red;">' + val + '</span>';
  43. }
  44. return val;
  45. }
  46. /**
  47. * Custom function used for column renderer
  48. * @param {Object} val
  49. */
  50. function pctChange(val) {
  51. if (val > 0) {
  52. return '<span style="color:green;">' + val + '%</span>';
  53. } else if (val < 0) {
  54. return '<span style="color:red;">' + val + '%</span>';
  55. }
  56. return val;
  57. }
  58. return {
  59. /*
  60. * ================ TabPanel with nested layouts =======================
  61. */
  62. tabsNestedLayouts: {
  63. xtype: 'tabpanel',
  64. id: 'tabs-nested-layouts-panel',
  65. title: 'TabPanel with Nested Layouts',
  66. activeTab: 0,
  67. items:[{
  68. title: 'Foo',
  69. layout: 'border',
  70. items: [{
  71. region: 'north',
  72. title: 'North',
  73. height: 75,
  74. maxSize: 150,
  75. margins: '5 5 0 5',
  76. bodyStyle: 'padding:10px;',
  77. split: true,
  78. html: 'Some content'
  79. },{
  80. xtype: 'tabpanel',
  81. plain: true,
  82. region: 'center',
  83. margins: '0 5 5 5',
  84. activeTab: 0,
  85. items: [{
  86. title: 'Inner Tab 1',
  87. bodyStyle: 'padding:10px;',
  88. html: 'See Inner Tab 2 for another nested BorderLayout.'
  89. },{
  90. title: 'Inner Tab 2',
  91. cls: 'inner-tab-custom', // custom styles in layout-browser.css
  92. layout: 'border',
  93. // Make sure IE can still calculate dimensions after a resize when the tab is not active.
  94. // With display mode, if the tab is rendered but hidden, IE will mess up the layout on show:
  95. hideMode: Ext.isIE ? 'offsets' : 'display',
  96. items: [{
  97. title: 'West',
  98. region: 'west',
  99. collapsible: true,
  100. width: 150,
  101. minSize: 100,
  102. maxSize: 350,
  103. margins: '5 0 5 5',
  104. cmargins: '5 5 5 5',
  105. html: 'Hello',
  106. bodyStyle:'padding:10px;',
  107. split: true
  108. },{
  109. xtype: 'tabpanel',
  110. region: 'center',
  111. margins: '5 5 5 0',
  112. tabPosition: 'bottom',
  113. activeTab: 0,
  114. items: [{
  115. // Panels that are used as tabs do not have title bars since the tab
  116. // itself is the title container. If you want to have a full title
  117. // bar within a tab, you can easily nest another panel within the tab
  118. // with layout:'fit' to acheive that:
  119. title: 'Bottom Tab',
  120. layout: 'fit',
  121. items: {
  122. title: 'Interior Content',
  123. bodyStyle:'padding:10px;',
  124. border: false,
  125. html: 'See the next tab for a nested grid. The grid is not rendered until its tab is first accessed.'
  126. }
  127. },{
  128. // A common mistake when adding grids to a layout is creating a panel first,
  129. // then adding the grid to it. GridPanel (xtype:'grid') is a Panel subclass,
  130. // so you can add it directly as an item into a container. Typically you will
  131. // want to specify layout:'fit' on GridPanels so that they'll size along with
  132. // their container and take up the available space.
  133. title: 'Nested Grid',
  134. xtype: 'grid',
  135. layout: 'fit',
  136. store: Ext.create('Ext.data.ArrayStore', {
  137. fields: [
  138. {name: 'company'},
  139. {name: 'price', type: 'float'},
  140. {name: 'change', type: 'float'},
  141. {name: 'pctChange', type: 'float'},
  142. {name: 'lastChange', type: 'date', dateFormat: 'n/j h:ia'}
  143. ],
  144. data: myData
  145. }),
  146. columns: [
  147. {
  148. text : 'Company',
  149. flex : 1,
  150. sortable : false,
  151. dataIndex: 'company'
  152. },
  153. {
  154. text : 'Price',
  155. width : 75,
  156. sortable : true,
  157. renderer : 'usMoney',
  158. dataIndex: 'price'
  159. },
  160. {
  161. text : 'Change',
  162. width : 75,
  163. sortable : true,
  164. renderer : change,
  165. dataIndex: 'change'
  166. },
  167. {
  168. text : '% Change',
  169. width : 75,
  170. sortable : true,
  171. renderer : pctChange,
  172. dataIndex: 'pctChange'
  173. },
  174. {
  175. text : 'Last Updated',
  176. width : 85,
  177. sortable : true,
  178. renderer : Ext.util.Format.dateRenderer('m/d/Y'),
  179. dataIndex: 'lastChange'
  180. }
  181. ],
  182. stripeRows: true
  183. }]
  184. }]
  185. }]
  186. }]
  187. },{
  188. title: 'Bar',
  189. bodyStyle: 'padding:10px;',
  190. html: 'Nothing to see here.'
  191. }]
  192. },
  193. /*
  194. * ================ Absolute Layout Form =======================
  195. */
  196. // absform: ,
  197. absoluteForm: {
  198. title: 'Absolute Layout Form',
  199. id: 'abs-form-panel',
  200. layout: 'fit',
  201. bodyPadding: 15,
  202. items: {
  203. title: 'New Email',
  204. layout: 'fit',
  205. frame: true,
  206. items: {
  207. xtype: 'form',
  208. layout:'absolute',
  209. url:'save-form.php',
  210. padding: '5 5 0 5',
  211. border: false,
  212. cls: 'absolute-form-panel-body',
  213. defaultType: 'textfield',
  214. items: [{
  215. x: 0,
  216. y: 5,
  217. xtype: 'label',
  218. text: 'From:'
  219. },{
  220. x: 55,
  221. y: 0,
  222. name: 'from',
  223. hideLabel: true,
  224. anchor:'100%' // anchor width by %
  225. },{
  226. x: 0,
  227. y: 32,
  228. xtype: 'label',
  229. text: 'To:'
  230. },{
  231. x: 55,
  232. y: 27,
  233. xtype: 'button',
  234. text: 'Contacts...'
  235. },{
  236. x: 127,
  237. y: 27,
  238. name: 'to',
  239. hideLabel: true,
  240. anchor: '100%' // anchor width by %
  241. },{
  242. x: 0,
  243. y: 59,
  244. xtype: 'label',
  245. text: 'Subject:'
  246. },{
  247. x: 55,
  248. y: 54,
  249. name: 'subject',
  250. hideLabel: true,
  251. anchor: '100%' // anchor width by %
  252. },{
  253. x: 0,
  254. y: 81,
  255. hideLabel: true,
  256. xtype: 'textarea',
  257. name: 'msg',
  258. anchor: '100% 100%' // anchor width and height
  259. }]
  260. },
  261. dockedItems: [
  262. {
  263. xtype: 'toolbar',
  264. ignoreParentFrame: true,
  265. ignoreBorderManagement: true,
  266. cls: 'absolute-form-toolbar',
  267. items: [
  268. {
  269. text: 'Send',
  270. iconCls: 'icon-send'
  271. },'-',{
  272. text: 'Save',
  273. iconCls: 'icon-save'
  274. },{
  275. text: 'Check Spelling',
  276. iconCls: 'icon-spell'
  277. },'-',{
  278. text: 'Print',
  279. iconCls: 'icon-print'
  280. },'->',{
  281. text: 'Attach a File',
  282. iconCls: 'icon-attach'
  283. }
  284. ]
  285. }
  286. ]
  287. }
  288. }
  289. };
  290. }