SysCheckWinGrid.js.svn-base 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. Ext.define('erp.view.ma.SysCheckWinGrid',{
  2. extend: 'Ext.grid.Panel',
  3. alias: 'widget.erpSysCheckWinGrid',
  4. requires: ['erp.view.core.toolbar.Toolbar'],
  5. id: 'wingrid',
  6. emptyText : $I18N.common.grid.emptyText,
  7. columnLines : true,
  8. autoScroll : true,
  9. store: [],
  10. columns: [],
  11. bodyStyle: 'background-color:#f1f1f1;',
  12. plugins: [Ext.create('Ext.grid.plugin.CellEditing', {
  13. clicksToEdit: 1
  14. })],
  15. GridUtil: Ext.create('erp.util.GridUtil'),
  16. BaseUtil: Ext.create('erp.util.BaseUtil'),
  17. necessaryField: '',//必填字段
  18. detno: '',//编号字段
  19. keyField: '',//主键字段
  20. mainField: '',//对应主表主键的字段
  21. dbfinds: [],
  22. caller: null,
  23. condition: null,
  24. initComponent : function(){
  25. var condition = this.condition;
  26. if(!condition){
  27. var urlCondition = this.BaseUtil.getUrlParam('gridCondition');
  28. urlCondition = urlCondition == null || urlCondition == "null" ? "" : urlCondition;
  29. gridCondition = (gridCondition == null || gridCondition == "null") ? "" : gridCondition;
  30. gridCondition = gridCondition + urlCondition;
  31. gridCondition = gridCondition.replace(/IS/g, "=");
  32. /*if(gridCondition.search(/!/) != -1){
  33. gridCondition = gridCondition.substring(0, gridCondition.length - 4);
  34. }*/
  35. condition = gridCondition;
  36. }
  37. var gridParam = {caller: this.caller || caller, condition: condition};
  38. this.GridUtil.getGridColumnsAndStore(this, 'common/singleGridPanel.action', gridParam, "");//从后台拿到gridpanel的配置及数据
  39. this.callParent(arguments);
  40. },
  41. getEffectiveData: function(){
  42. var me = this;
  43. var effective = new Array();
  44. var s = this.store.data.items;
  45. for(var i=0;i<s.length;i++){
  46. var data = s[i].data;
  47. if(data[me.keyField] != null && data[me.keyField] != ""){
  48. effective.push(data);
  49. }
  50. }
  51. return effective;
  52. },
  53. setReadOnly: function(bool){
  54. this.readOnly = bool;
  55. },
  56. reconfigure: function(store, columns){
  57. var d = this.headerCt;
  58. if (this.columns.length <= 1 && columns) {
  59. d.suspendLayout = true;
  60. d.removeAll();
  61. d.add(columns);
  62. }
  63. if (store) {
  64. try{
  65. this.bindStore(store);
  66. } catch (e){
  67. }
  68. } else {
  69. this.getView().refresh();
  70. }
  71. if (columns) {
  72. d.suspendLayout = false;
  73. this.forceComponentLayout();
  74. }
  75. this.fireEvent("reconfigure", this);
  76. },
  77. listeners: {
  78. afterrender: function(grid){
  79. var me = this;
  80. if(Ext.isIE){
  81. document.body.attachEvent('onkeydown', function(){
  82. if(window.event.ctrlKey && window.event.keyCode == 67){//Ctrl + C
  83. var e = window.event;
  84. if(e.srcElement) {
  85. window.clipboardData.setData('text', e.srcElement.innerHTML);
  86. }
  87. }
  88. });
  89. } else {
  90. document.body.addEventListener("mouseover", function(e){
  91. if(Ext.isFF5){
  92. e = e || window.event;
  93. }
  94. window.mouseoverData = e.target.value;
  95. });
  96. document.body.addEventListener("keydown", function(e){
  97. if(Ext.isFF5){
  98. e = e || window.event;
  99. }
  100. if(e.ctrlKey && e.keyCode == 67){
  101. me.copyToClipboard(window.mouseoverData);
  102. }
  103. if(e.ctrlKey && e.keyCode == 67){
  104. me.copyToClipboard(window.mouseoverData);
  105. }
  106. });
  107. }
  108. }
  109. },
  110. copyToClipboard: function(txt) {
  111. if(window.clipboardData) {
  112. window.clipboardData.clearData();
  113. window.clipboardData.setData('text', txt);
  114. } else if (navigator.userAgent.indexOf('Opera') != -1) {
  115. window.location = txt;
  116. } else if (window.netscape) {
  117. try {
  118. netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
  119. } catch (e) {
  120. alert("您的firefox安全限制限制您进行剪贴板操作,请打开'about:config'将signed.applets.codebase_principal_support'设置为true'之后重试");
  121. return false;
  122. }
  123. }
  124. }
  125. });