Viewport.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. model: 'Temp'
  37. });
  38. return Ext.create('Ext.grid.Panel', {
  39. anchor: '100% 100%',
  40. id : 'querygrid',
  41. cls : 'default-grid',
  42. maxDataSize: 30000,
  43. loadMask: true,
  44. plugins: 'bufferedrenderer',
  45. selModel: {
  46. pruneRemoved: false
  47. },
  48. viewConfig: {
  49. trackOver: true
  50. },
  51. BaseUtil: Ext.create('erp.util.BaseUtil'),
  52. RenderUtil: Ext.create('erp.util.RenderUtil'),
  53. features : [{
  54. id: 'group',
  55. ftype: 'groupingsummary',
  56. hideGroupedHeader: true,
  57. enableGroupingMenu: false
  58. },{
  59. ftype: 'summary',
  60. dock: 'bottom'
  61. }],
  62. enableLocking : true,
  63. lockable : true,
  64. selModel: {
  65. selType: 'cellmodel'
  66. },
  67. columns: columns,
  68. store: store,
  69. columnLines: true,
  70. tbar: [{
  71. text: '筛选', iconCls: 'icon-find', name: 'find'
  72. },{
  73. text: '排序', iconCls: 'icon-sort', name: 'sort'
  74. },{
  75. text: '导出',
  76. iconCls: 'icon-xls',
  77. menu: [{text: '导出Excel (.xls)', iconCls: 'icon-xls', name: 'exportexcel'}, {text: '导出PDF (.pdf)', iconCls: 'icon-pdf', name: 'exportpdf'}]
  78. },{
  79. text: '锁定列',
  80. iconCls: 'icon-fixed',
  81. name: 'lock'
  82. }/*,{
  83. text: '公式',
  84. iconCls: 'icon-sum',
  85. menu: [{text: '总数', iconCls: 'icon-sum', name: 'sum'}, {text: '平均值', iconCls: 'icon-avg', name: 'average'}]
  86. }*/,{
  87. text: '分组',
  88. iconCls: 'icon-group',
  89. name: 'group'
  90. },'-',{
  91. xtype: 'tbtext',
  92. id: 'dataCount',
  93. hidden: true,
  94. tpl: Ext.create('Ext.XTemplate','为您找到 <strong>{count}</strong> 条数据')
  95. },'->',{
  96. iconCls: 'icon-maximize',
  97. text: '切换',
  98. menu: [{text: '最大化', name: 'max', iconCls: 'icon-maximize'},{text: 'Web Excel', name: 'webexcel', iconCls: 'icon-amp'}]
  99. },{
  100. text: '清除格式', iconCls: 'icon-remove',cls: 'custom-btn', name: 'removeformat'
  101. },{
  102. text: '清除数据', iconCls: 'icon-clear', name: 'clearall'
  103. },{
  104. text: '关闭', name: 'close', iconCls: 'icon-del'
  105. }]
  106. });
  107. }
  108. });