details:   /erp/devel/pi/rev/5d663c7f5bd6
changeset: 12072:5d663c7f5bd6
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Tue May 10 05:59:34 2011 +0200
summary:   Fixes issue 17072: Default sort defined in ad_field is not taking 
into account

diffstat:

 
modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-grid.js.ftl
   |   1 +
 
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewGridComponent.java
 |  28 +++++++++-
 2 files changed, 28 insertions(+), 1 deletions(-)

diffs (56 lines):

diff -r 72dfdbf5b8da -r 5d663c7f5bd6 
modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-grid.js.ftl
--- 
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-grid.js.ftl
       Tue May 10 05:39:33 2011 +0200
+++ 
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-grid.js.ftl
       Tue May 10 05:59:34 2011 +0200
@@ -103,6 +103,7 @@
     ],
     whereClause: '${data.whereClause?js_string}',
     orderByClause: '${data.orderByClause?js_string}',
+    sortField: '${data.sortField?js_string}',
     filterClause: '${data.filterClause?js_string}',
     
     foreignKeyFieldNames:[
diff -r 72dfdbf5b8da -r 5d663c7f5bd6 
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewGridComponent.java
--- 
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewGridComponent.java
     Tue May 10 05:39:33 2011 +0200
+++ 
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewGridComponent.java
     Tue May 10 05:59:34 2011 +0200
@@ -89,6 +89,27 @@
     if (tab.getHqlorderbyclause() != null) {
       return tab.getHqlorderbyclause();
     }
+
+    return "";
+  }
+
+  public String getSortField() {
+    if (getOrderByClause().length() > 0) {
+      return "";
+    }
+
+    long lowestSortno = Long.MAX_VALUE;
+    LocalField sortByField = null;
+    for (LocalField localField : getFields()) {
+      final Long recordSortno = localField.getField().getRecordSortNo();
+      if (localField.isInitialShow() && recordSortno != null && recordSortno < 
lowestSortno) {
+        sortByField = localField;
+      }
+    }
+    if (sortByField != null && sortByField.getProperty() != null) {
+      return sortByField.getProperty().getName();
+    }
+
     // use 2 examples of sequence number of line no
     if (entity.hasProperty(Tab.PROPERTY_SEQUENCENUMBER)) {
       return Tab.PROPERTY_SEQUENCENUMBER;
@@ -97,7 +118,12 @@
       return OrderLine.PROPERTY_LINENO;
     }
 
-    return JsonConstants.IDENTIFIER;
+    for (LocalField localField : getFields()) {
+      if (localField.getProperty() != null && 
localField.getProperty().isIdentifier()) {
+        return localField.getProperty().getName();
+      }
+    }
+    return "";
   }
 
   public String getFilterClause() {

------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to