Summary row should not show links and link styling, prevent whole cell from being clickable
authorMartin Taal <martin.taal@openbravo.com>
Thu, 30 Dec 2010 14:00:35 +0100
changeset 9498 ac4ce201819f
parent 9497 219f03915fa8
child 9499 7191314bb53e
Summary row should not show links and link styling, prevent whole cell from being clickable
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-grid.js
modules/org.openbravo.client.application/web/org.openbravo.userinterface.smartclient/openbravo/skins/3.00/org.openbravo.client.application/ob-grid-styles.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-grid.js	Thu Dec 30 13:31:36 2010 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-grid.js	Thu Dec 30 14:00:35 2010 +0100
@@ -32,7 +32,7 @@
   createRecordComponent: function(record, colNum){
     var field = this.getField(colNum), rowNum = this.getRecordIndex(record);
     if (field.isLink && record[field.name]) {
-      var linkButton = isc.OBGridLinkButton.create({
+      var linkButton = isc.OBGridLinkLayout.create({
         grid: this,
         align: this.getCellAlign(record, rowNum, colNum),
         title: this.formatLinkValue(record, field, colNum, rowNum, record[field.name]),
@@ -91,6 +91,34 @@
     return this.Super('initWidget', arguments);
   },
   
+  showSummaryRow: function(){
+    var i, fld, fldsLength, newFields = [];
+    var ret = this.Super("showSummaryRow", arguments);
+    if (this.summaryRow && !this.summaryRowFieldRepaired) {
+      // the summaryrow shares the same field instances as the 
+      // original grid, this must be repaired as the grid and
+      // and the summary row need different behavior.
+      // copy the fields and repair specific parts
+      // don't support links in the summaryrow
+      fldsLength = this.summaryRow.fields.length;
+      for (i = 0; i < fldsLength; i++) {
+        fld = isc.addProperties({}, this.summaryRow.fields[i]);
+        newFields[i] = fld;
+        fld.isLink = false;
+        if (fld.originalFormatCellValue) {
+          fld.formatCellValue = fld.originalFormatCellValue;
+          fld.originalFormatCellValue = null;
+        } else {
+          fld.formatCellValue = null;
+        }
+      }
+      this.summaryRow.isSummaryRow = true;
+      this.summaryRowFieldRepaired = true;
+      this.summaryRow.setFields(newFields);
+    }
+    return ret;
+  },
+  
   // = exportData =
   // The exportData function exports the data of the grid to a file. The user will 
   // be presented with a save-as dialog.
@@ -130,11 +158,39 @@
 
 isc.ClassFactory.defineClass('OBGridHeaderImgButton', isc.ImgButton);
 
-isc.ClassFactory.defineClass('OBGridLinkButton', isc.Button);
-isc.OBGridLinkButton.addProperties({
-  action: function(){
-    if (this.grid && this.grid.cellClick) {
+isc.ClassFactory.defineClass('OBGridLinkLayout', isc.HLayout);
+isc.OBGridLinkLayout.addProperties({
+  overflow: 'clip-h',
+  btn: null,
+  height: 1,
+  width: '100%',
+  
+  initWidget: function() {
+    this.btn = isc.OBGridLinkButton.create({});
+    this.btn.setTitle(this.title);
+    this.btn.owner = this;
+    this.addMember(this.btn);
+    return this.Super("initWidget", arguments);
+  },
+  
+  setTitle: function(title) {
+    this.btn.setTitle(title);
+  },
+  
+  doAction: function(){
+    if (this.grid && this.grid.doCellClick) {
+      this.grid.doCellClick(this.record, this.rowNum, this.colNum);
+    } else if (this.grid && this.grid.cellClick) {
       this.grid.cellClick(this.record, this.rowNum, this.colNum);
     }
   }
+
 });
+
+isc.ClassFactory.defineClass('OBGridLinkButton', isc.Button);
+
+isc.OBGridLinkButton.addProperties({
+  action: function(){
+    this.owner.doAction();
+  }
+});
--- a/modules/org.openbravo.client.application/web/org.openbravo.userinterface.smartclient/openbravo/skins/3.00/org.openbravo.client.application/ob-grid-styles.js	Thu Dec 30 13:31:36 2010 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.userinterface.smartclient/openbravo/skins/3.00/org.openbravo.client.application/ob-grid-styles.js	Thu Dec 30 14:00:35 2010 +0100
@@ -127,6 +127,7 @@
   showFocused: true,
   showFocusedAsOver: true,
   showRollOver: true,
-  width: '100%',
-  height: '100%'
+  autoFit: true,
+  height: 1,
+  overflow: 'visible'
 });
\ No newline at end of file