GridPanel.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. Ext.define('erp.view.fa.fix.mQuery.GridPanel',{
  2. extend: 'Ext.grid.Panel',
  3. alias: 'widget.erpMQueryGridPanel',
  4. id: 'mquerygrid',
  5. emptyText : '无数据',
  6. columnLines : true,
  7. autoScroll : true,
  8. store: [],
  9. columns: [],
  10. tbar: [{
  11. name: 'query',
  12. text: $I18N.common.button.erpQueryButton,
  13. iconCls: 'x-button-icon-query',
  14. cls: 'x-btn-gray'
  15. }, '->', {
  16. name: 'export',
  17. text: $I18N.common.button.erpExportButton,
  18. iconCls: 'x-button-icon-submit',
  19. cls: 'x-btn-gray',
  20. handler: function(btn){
  21. var grid = Ext.getCmp('querygrid');
  22. var condition = grid.defaultCondition || '';
  23. grid.BaseUtil.createExcel(caller, 'detailgrid', btn.ownerCt.ownerCt.spellCondition(condition));
  24. }
  25. }, '-', {
  26. text: $I18N.common.button.erpCloseButton,
  27. iconCls: 'x-button-icon-close',
  28. cls: 'x-btn-gray',
  29. handler: function(){
  30. var main = parent.Ext.getCmp("content-panel");
  31. main.getActiveTab().close();
  32. }
  33. }],
  34. GridUtil: Ext.create('erp.util.GridUtil'),
  35. selModel: Ext.create('Ext.selection.CheckboxModel',{
  36. headerWidth: 0
  37. }),
  38. plugins: [Ext.create('Ext.ux.grid.GridHeaderFilters')],
  39. BaseUtil: Ext.create('erp.util.BaseUtil'),
  40. FormUtil: Ext.create('erp.util.FormUtil'),
  41. features : [Ext.create('Ext.grid.feature.Grouping',{
  42. hideGroupedHeader: true,
  43. groupHeaderTpl: '{name} (Count:{rows.length})'
  44. }),{
  45. ftype : 'summary',
  46. showSummaryRow : false,//不显示默认合计行
  47. generateSummaryData: function(){
  48. var me = this,
  49. data = {},
  50. store = me.view.store,
  51. columns = me.view.headerCt.getColumnsForTpl(),
  52. i = 0,
  53. length = columns.length,
  54. //fieldData,
  55. //key,
  56. comp;
  57. for (i = 0, length = columns.length; i < length; ++i) {
  58. comp = Ext.getCmp(columns[i].id);
  59. data[comp.id] = me.getSummary(store, comp.summaryType, comp.dataIndex, false);
  60. var tb = Ext.getCmp(columns[i].dataIndex + '_' + comp.summaryType);
  61. if(tb){
  62. tb.setText(tb.text.split(':')[0] + ':' + data[comp.id]);
  63. }
  64. }
  65. return data;
  66. }
  67. }],
  68. initComponent : function(){
  69. condition = this.BaseUtil.getUrlParam('urlcondition');
  70. condition = (condition == null) ? "" : condition;
  71. condition = condition.replace(/@/,"'%").replace(/@/,"%'");
  72. this.defaultCondition = condition;
  73. var gridParam = {caller: caller, condition: condition};
  74. this.GridUtil.getGridColumnsAndStore(this, 'common/singleGridPanel.action', gridParam, "");
  75. this.callParent(arguments);
  76. },
  77. summary: function(){
  78. var me = this,
  79. store = this.store,
  80. value;
  81. Ext.each(me.columns, function(c){
  82. if(c.summaryType == 'sum'){
  83. value = store.getSum(store.data.items, c.dataIndex);
  84. me.down('tbtext[id=' + c.dataIndex + '_sum]').setText(c.header + '(sum):' + value);
  85. } else if(c.summaryType == 'count'){
  86. value = store.getCount();
  87. me.down('tbtext[id=' + c.dataIndex + '_count]').setText(c.header + '(count):' + value);
  88. } else if(c.summaryType == 'average'){
  89. value = store.getAverage(c.dataIndex);
  90. me.down('tbtext[id=' + c.dataIndex + '_average]').setText(c.header + '(average):' + value);
  91. }
  92. });
  93. },
  94. listeners: {
  95. 'headerfiltersapply': function(grid, filters) {
  96. grid.summary();
  97. return true;
  98. }/*,
  99. 'itemclick':function(grid,record){
  100. var me = this;
  101. if(record.data.cm_showtype!='1'){
  102. me.FormUtil.onAdd('showCmDetail', "查询明细", 'jsps/fa/ars/showCmDetail.jsp?showtype='+record.data.cm_showtype+'&cmid='+record.data.cm_id+'&currency='+record.data.cm_currency+'&custcode='+record.data.cm_custcode+'&custname='+record.data.cu_name+'&yearmonth='+record.data.cm_yearmonth);
  103. }
  104. }*/
  105. },
  106. viewConfig: {
  107. getRowClass: function(record) {
  108. return record.get('cm_showtype')=='1'?'custom':'custom-alt';
  109. // return record.get('index')%2 == 0 ? (!Ext.isEmpty(record.get('cm_id')) ? 'custom-first' : 'custom') :
  110. // (!Ext.isEmpty(record.get('cm_id')) ? 'custom-alt-first' : 'custom-alt');
  111. }
  112. }
  113. });