Issue 10138: don't display 'data is null' when hovering over col with no rows
authorStefan Hühner <stefan.huehner@openbravo.com>
Wed, 23 Sep 2009 11:10:29 +0200
changeset 5071 97dd457bbb50
parent 5070 1c3767f18498
child 5072 9434157dc8fb
Issue 10138: don't display 'data is null' when hovering over col with no rows
- don't sent string 'undefined' instead of id-list with not rows selected
- use '0' when sql query returned null
src/org/openbravo/erpCommon/utility/DataGrid.java
web/js/openbravo/widget/DataGrid.js
--- a/src/org/openbravo/erpCommon/utility/DataGrid.java	Wed Sep 23 10:00:18 2009 +0200
+++ b/src/org/openbravo/erpCommon/utility/DataGrid.java	Wed Sep 23 11:10:29 2009 +0200
@@ -490,6 +490,10 @@
     String total = "0";
     if (data != null && data.length > 0)
       total = data[0].getField("TOTAL");
+    // fallback to default value when query returned null (i.e. with no rows in filter)
+    if (total == null) {
+      total = "0";
+    }
     XmlDocument xmlDocument = xmlEngine.readXmlTemplate(
         "org/openbravo/erpCommon/utility/DataGridTotal").createXmlDocument();
     xmlDocument.setParameter("total", total);
--- a/web/js/openbravo/widget/DataGrid.js	Wed Sep 23 10:00:18 2009 +0200
+++ b/web/js/openbravo/widget/DataGrid.js	Wed Sep 23 11:10:29 2009 +0200
@@ -897,12 +897,17 @@
 * @param {String} rowName - name of the row
 */
   requestColumnTotals: function(rowName){
+    // workaround request sent with rows='undefined' when no rows are selected
+    var rows = this.getSelectedRows();
+    if (rows == "") {
+      rows = "";
+    }
     setCalloutProcessing(true);
     var handlerRef = dojo.hitch(this, "showColumnTotals");
     var params = [];
     params["action"] = "getColumnTotals";
     params["columnName"] = rowName;
-    params["rows"] = this.getSelectedRows();
+    params["rows"] = rows;
     var serviceUrl = {
       url: this.dataUrl,
       handler: handlerRef,