details:   /erp/devel/pi/rev/69602041db1f
changeset: 12378:69602041db1f
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Tue May 24 14:51:20 2011 +0200
summary:   Related to issue 17188: Default sort column header has wrong styling

diffstat:

 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
 |  54 +++++++++-
 1 files changed, 52 insertions(+), 2 deletions(-)

diffs (85 lines):

diff -r 80b268e62009 -r 69602041db1f 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
  Tue May 24 13:52:12 2011 +0200
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
  Tue May 24 14:51:20 2011 +0200
@@ -84,6 +84,7 @@
   width: '100%',
   height: '100%',
   
+  showSortArrow: 'field',
   autoFetchTextMatchStyle: 'substring',
   showFilterEditor: true,
   canEdit: true,
@@ -267,7 +268,7 @@
     this.contextMenu = this.getMenuConstructor().create({items: menuItems});
 
     var ret = this.Super('initWidget', arguments);
-
+    
     this.noDataEmptyMessage = 
OB.I18N.getLabel('OBUISC_ListGrid.loadingDataMessage'); // 
OB.I18N.getLabel('OBUIAPP_GridNoRecords')
     this.filterNoRecordsEmptyMessage = 
OB.I18N.getLabel('OBUIAPP_GridFilterNoResults') +
     ' <span onclick="window[\'' +
@@ -275,7 +276,7 @@
     '\'].clearFilter();" class="OBLabelLink">' +
     OB.I18N.getLabel('OBUIAPP_GridClearFilter') +
     '</span>';
-
+    
     return ret;
   },
 
@@ -928,6 +929,55 @@
     }
   },
 
+  toggleSort: function(fieldName, direction) {
+    var fld = this.getField(fieldName);
+    if (fld && fld.displayField) {
+      this.Super('toggleSort', [fld.displayField, direction]);
+    } else {
+      this.Super('toggleSort', arguments);
+    }
+  },
+  
+  getSortSpecifier : function (fieldName) {
+    var fld = this.getField(fieldName), ret;
+    if (fld && fld.displayField) {
+      ret = this.Super('getSortSpecifier', [fld.displayField]);
+    } else {
+      ret = this.Super('getSortSpecifier', arguments);
+    }
+    return ret;
+  },
+
+  // overridden to solve an issue that for fields with a displayfield no 
+  // sort arrow is shown
+  setSort: function(sortSpecs) {
+    var i, specifier, dotIndex, sortHeader, sortButton, property, field, 
fieldNum, ret = this.Super('setSort', arguments);
+    
+    if (sortSpecs && sortSpecs.length > 0) {
+      // set the sort indicators on any fields that are sorted and are visible
+      for (i = 0; i < sortSpecs.length; i++) {
+        specifier = sortSpecs[i];
+        property = specifier.property;
+        if (!property.endsWith(OB.Constants.IDENTIFIER)) {
+          continue;
+        }
+        property = property.substring(0, property.length - 1 - 
OB.Constants.IDENTIFIER.length);
+        field = this.getSpecifiedField(property);
+        fieldNum = this.getFieldNum(property);
+        sortHeader = this.getFieldHeader(fieldNum);
+        sortButton = sortHeader.getMember(this.getLocalFieldNum(fieldNum));
+        if (sortButton) {
+          if (field) {
+            field.sortDirection = 
Array.shouldSortAscending(specifier.direction);
+          }
+          sortHeader.selectButton(sortButton);
+          sortButton.setTitle(this.getHeaderButtonTitle(sortButton));
+        }
+      }
+    }
+    return ret;
+  },
+  
   // determine which field can be autoexpanded to use extra space
   getAutoFitExpandField: function() {
     var i;

------------------------------------------------------------------------------
vRanger cuts backup time in half-while increasing security.
With the market-leading solution for virtual backup and recovery, 
you get blazing-fast, flexible, and affordable data protection.
Download your free trial now. 
http://p.sf.net/sfu/quest-d2dcopy1
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to