Viewport.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. Ext.define('erp.view.common.search.Viewport', {
  2. extend : 'Ext.Viewport',
  3. layout : 'anchor',
  4. hideBorders : true,
  5. initComponent : function() {
  6. var me = this;
  7. me.callParent(arguments);
  8. me.add(me.createGrid([], []));
  9. },
  10. getColumns: function(fn) {
  11. var me = this;
  12. Ext.Ajax.request({
  13. url : basePath + 'common/singleGridPanel.action',
  14. params: {
  15. caller: caller,
  16. condition: ''
  17. },
  18. method : 'post',
  19. callback : function(opt, s, r){
  20. var res = new Ext.decode(r.responseText);
  21. if(res.exceptionInfo){
  22. showError(res.exceptionInfo);return;
  23. }
  24. if(res.columns){
  25. fn.call(me, res.columns, res.fields);
  26. }
  27. }
  28. });
  29. },
  30. createGrid: function(columns, fields) {
  31. Ext.define('Temp', {
  32. extend: 'Ext.data.Model',
  33. fields: fields
  34. });
  35. var store = Ext.create('Ext.data.Store', {
  36. buffered: true,
  37. model: 'Temp'/*,
  38. proxy: {
  39. type: 'ajax',
  40. url: basePath + 'common/search.action',
  41. reader: {
  42. type: 'json',
  43. root: 'datas'
  44. }
  45. },
  46. autoLoad: false*/
  47. });
  48. return Ext.create('Ext.grid.Panel', {
  49. anchor: '100% 100%',
  50. id : 'querygrid',
  51. cls : 'default-grid',
  52. maxDataSize: 30000,
  53. loadMask: true,
  54. plugins: 'bufferedrenderer',
  55. selModel: {
  56. pruneRemoved: false
  57. },
  58. viewConfig: {
  59. trackOver: true
  60. },
  61. BaseUtil: Ext.create('erp.util.BaseUtil'),
  62. RenderUtil: Ext.create('erp.util.RenderUtil'),
  63. features : [{
  64. id: 'group',
  65. ftype: 'groupingsummary',
  66. // hideGroupedHeader: true,
  67. // enableGroupingMenu: false,
  68. showSummaryRow: true
  69. },{
  70. ftype: 'summary',
  71. dock: 'bottom'
  72. }],
  73. enableLocking : true,
  74. lockable : true,
  75. selModel: {
  76. selType: 'cellmodel'
  77. },
  78. columns: columns,
  79. store: store,
  80. columnLines: true,
  81. tbar: [{
  82. text: '筛选', iconCls: 'icon-find', name: 'find'
  83. },{
  84. text: '排序', iconCls: 'icon-sort', name: 'sort'
  85. },{
  86. text: '导出',
  87. iconCls: 'icon-xls',
  88. menu: [{text: '导出Excel (.xls)', iconCls: 'icon-xls', name: 'exportexcel'}, {text: '导出PDF (.pdf)', iconCls: 'icon-pdf', name: 'exportpdf'}]
  89. },{
  90. text: '锁定列',
  91. iconCls: 'icon-fixed',
  92. name: 'lock'
  93. }/*,{
  94. text: '公式',
  95. iconCls: 'icon-sum',
  96. menu: [{text: '总数', iconCls: 'icon-sum', name: 'sum'}, {text: '平均值', iconCls: 'icon-avg', name: 'average'}]
  97. }*/,{
  98. text: '分组',
  99. iconCls: 'icon-group',
  100. name: 'group'
  101. },'-',{
  102. xtype: 'tbtext',
  103. id: 'dataCount',
  104. hidden: true,
  105. tpl: Ext.create('Ext.XTemplate','为您找到 <strong>{count}</strong> 条数据')
  106. },'->',{
  107. iconCls: 'icon-maximize',
  108. text: '切换',
  109. menu: [{text: '最大化', name: 'max', iconCls: 'icon-maximize'},{text: 'Web Excel', name: 'webexcel', iconCls: 'icon-amp'}]
  110. },{
  111. text: '清除格式', iconCls: 'icon-remove',cls: 'custom-btn', name: 'removeformat'
  112. },{
  113. text: '清除数据', iconCls: 'icon-clear', name: 'clearall'
  114. },{
  115. text: '关闭', name: 'close', iconCls: 'icon-del'
  116. }]
  117. });
  118. }
  119. });