Panel.js 4.8 KB

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