Panel.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. /**
  2. * This example illustrates how to use the "gridexporter" plugin.
  3. */
  4. Ext.define('uas.view.grid.Exporter', {
  5. extend: 'Ext.grid.Panel',
  6. xtype: 'grid-exporter',
  7. controller: 'grid-exporter',
  8. requires: [
  9. 'Ext.grid.plugin.Exporter'
  10. ],
  11. loadMask: true,
  12. plugins: {
  13. gridexporter: true
  14. },
  15. store: {
  16. type: 'products',
  17. url: 'data/grid/grid-filter.json',
  18. autoLoad: true,
  19. autoDestroy: true,
  20. grouper: {
  21. property: 'size'
  22. }
  23. },
  24. features: [{
  25. ftype : 'groupingsummary',
  26. groupHeaderTpl : '{name}',
  27. hideGroupedHeader : false,
  28. enableGroupingMenu : false
  29. }, {
  30. ftype: 'summary',
  31. dock: 'bottom'
  32. }],
  33. listeners: {
  34. // this event notifies us when the document was saved
  35. documentsave: 'onDocumentSave',
  36. beforedocumentsave: 'onBeforeDocumentSave',
  37. dataready: 'onDataReady'
  38. },
  39. columns: [{
  40. dataIndex: 'id',
  41. text: 'Id',
  42. width: 50
  43. }, {
  44. dataIndex: 'company',
  45. text: 'Company',
  46. flex: 1,
  47. summaryType: 'count'
  48. }, {
  49. text: 'Info',
  50. columns: [{
  51. dataIndex: 'price',
  52. text: 'Price',
  53. width: 90,
  54. formatter: 'usMoney',
  55. summaryType: 'sum',
  56. summaryFormatter: 'usMoney',
  57. // you can define an export style for a column
  58. // you can set alignment, format etc
  59. exportStyle: [{
  60. // no type key is defined here which means that this is the default style
  61. // that will be used by all exporters
  62. format: 'Currency',
  63. alignment: {
  64. horizontal: 'Right'
  65. }
  66. },{
  67. // the type key means that this style will only be used by the html exporter
  68. // and for all others the default one, defined above, will be used
  69. type: 'html',
  70. format: 'Currency',
  71. alignment: {
  72. horizontal: 'Right'
  73. },
  74. font: {
  75. bold: true,
  76. italic: true
  77. }
  78. }]
  79. }, {
  80. dataIndex: 'size',
  81. text: 'Size',
  82. width: 120
  83. }, {
  84. xtype: 'datecolumn',
  85. dataIndex: 'date',
  86. text: 'Date',
  87. width: 120,
  88. // you can define an export style for a column
  89. // you can set alignment, format etc
  90. exportStyle: {
  91. alignment: {
  92. horizontal: 'Right'
  93. },
  94. format: 'Short Date'
  95. }
  96. }, {
  97. dataIndex: 'visible',
  98. text: 'Visible',
  99. width: 80,
  100. // some columns can be ignored during export
  101. ignoreExport: true
  102. }]
  103. }],
  104. header: {
  105. itemPosition: 1, // after title before collapse tool
  106. items: [{
  107. ui: 'default-toolbar',
  108. xtype: 'button',
  109. text: 'Export to ...',
  110. menu: {
  111. defaults: {
  112. handler: 'exportTo'
  113. },
  114. items: [{
  115. text: 'Excel xlsx',
  116. cfg: {
  117. type: 'excel07',
  118. ext: 'xlsx'
  119. }
  120. },{
  121. text: 'Excel xlsx (include groups)',
  122. cfg: {
  123. type: 'excel07',
  124. ext: 'xlsx',
  125. includeGroups: true,
  126. includeSummary: true
  127. }
  128. },{
  129. text: 'Excel xml',
  130. cfg: {
  131. type: 'excel03',
  132. ext: 'xml'
  133. }
  134. },{
  135. text: 'Excel xml (include groups)',
  136. cfg: {
  137. includeGroups: true,
  138. includeSummary: true,
  139. type: 'excel03',
  140. ext: 'xml'
  141. }
  142. },{
  143. text: 'CSV',
  144. cfg: {
  145. type: 'csv'
  146. }
  147. },{
  148. text: 'TSV',
  149. cfg: {
  150. type: 'tsv',
  151. ext: 'csv'
  152. }
  153. },{
  154. text: 'HTML',
  155. cfg: {
  156. type: 'html'
  157. }
  158. },{
  159. text: 'HTML (include groups)',
  160. cfg: {
  161. type: 'html',
  162. includeGroups: true,
  163. includeSummary: true
  164. }
  165. }]
  166. }
  167. }]
  168. }
  169. });